Skip to content

Commit

Permalink
Save Andrew's tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ramirez committed Jul 10, 2024
1 parent b2b4905 commit 3dd554c
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions pf2rnaseq/figures/figureLupus1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
XX:
"""
from matplotlib.pylab import eig
import plotly.express as px
# import plotly.express as px
from anndata import read_h5ad
from ..imports import pseudobulk_lupus
from .common import subplotLabel, getSetup
Expand All @@ -14,30 +14,51 @@
import matplotlib.pyplot as plt






def makeFigure():
"""Get a list of the axis objects and create a figure."""
# Get list of axis objects
ax, f = getSetup((30, 8), (2, 4))
ax, f = getSetup((9, 9), (3, 3))

# Add subplot labels
subplotLabel(ax)


X = read_h5ad("/opt/andrew/lupus/lupus_fitted_ann.h5ad")

bulk_matrix, bulk_tensor = pseudobulk_lupus(X)
print(bulk_matrix )
# bulk_matrix_genes_only = bulk_matrix.iloc[:, 2:-1]

# pca = PCA(n_components=2)
# principalComponents = pca.fit_transform(bulk_matrix_genes_only)
# print(np.shape(principalComponents))

# sns.scatterplot(data=data, x="PC1", y="PC2", hue="Status", ax=ax[0])



bulk_matrix = bulk_matrix.iloc[[0, 1, 10, 11], :]
bulk_matrix = bulk_matrix.iloc[:, [0, 1, 2, 3, 4, -1]]

bulk_matrix_genes_only = bulk_matrix.iloc[:, 2:5]
print(bulk_matrix_genes_only)

pca = PCA(n_components=2)
scores = pca.fit(bulk_matrix_genes_only).transform(bulk_matrix_genes_only)
loadings = pca.components_.T

print(np.shape(scores))
print(np.shape(loadings))

scores_df = pd.DataFrame(data = scores, columns = ["PC1", "PC2"])
loadings_df = pd.DataFrame(data = loadings, columns = ["PC1", "PC2"])

loadings_df["Gene"] = bulk_matrix_genes_only.columns.to_numpy()
sns.scatterplot(data=loadings_df, x="PC1", y="PC2", hue="Gene", ax=ax[4])

print(loadings_df)


# sns.scatterplot(data=scores_df, x="PC1", y="PC2", ax=ax[0])

# scores_df["Status"] = bulk_matrix["Status"].to_numpy()
# scores_df["Condition"] = bulk_matrix["Condition"].to_numpy()
# scores_df["Cell Type"] = bulk_matrix["Cell Type"].to_numpy()

# sns.scatterplot(data=scores_df, x="PC1", y="PC2", hue="Status", ax=ax[1])
# sns.scatterplot(data=scores_df, x="PC1", y="PC2", hue="Condition", ax=ax[2])
# sns.scatterplot(data=scores_df, x="PC1", y="PC2", hue="Cell Type", ax=ax[3])

# url = (bulk_matrix)

Expand Down

0 comments on commit 3dd554c

Please sign in to comment.