Skip to content

Commit

Permalink
Merge branch 'main' into fc_int2
Browse files Browse the repository at this point in the history
  • Loading branch information
bio-la committed Mar 19, 2024
2 parents 70d0bec + 224b8ea commit 3f3c17b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/integration01-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
run: |
cd teaseq/integration
curl -o pipeline.yml https://raw.githubusercontent.com/DendrouLab/panpipes/main/tests/integration_1/pipeline.yml
- name: Replace template contents in configuration file
run: |
cd teaseq/integration
Expand Down
31 changes: 21 additions & 10 deletions panpipes/python_scripts/batch_correct_multivi.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
sc.settings.autoshow = False
sc.settings.figdir = args.figdir


scvi.settings.seed = 1492
# load parameters

threads_available = multiprocessing.cpu_count()
Expand All @@ -71,17 +71,19 @@
# ------------------------------------------------------------------
L.info("Running multivi")

# mdata = mu.read(args.scaled_anndata)
# rna = mdata['rna'].copy()
# atac = mdata['atac'].copy()
rna= mu.read(args.scaled_anndata +"/" + "rna")
atac= mu.read(args.scaled_anndata +"/" + "atac")
mdata = mu.read(args.scaled_anndata)
rna = mdata['rna'].copy()
atac = mdata['atac'].copy()

del mdata

if check_for_bool(params["multimodal"]["MultiVI"]["lowmem"]):
L.info("subsetting atac to top 25k HVF")
if 'hvg' in atac.uns.keys():
L.info("subsetting atac to top HVF")
atac = atac[:, atac.var.highly_variable].copy()
L.info("calculating and subsetting atac to top 25k HVF")
sc.pp.highly_variable_genes(atac, n_top_genes=25000)
atac = atac[:, atac.var.highly_variable]
atac = atac[:, atac.var.highly_variable].copy()



Expand Down Expand Up @@ -126,6 +128,15 @@
L.info("concatenating modalities to comply with multiVI")
# adata_paired = ad.concat([rna, atac], join="outer")
# adata_paired.var = pd.concat([rna.var,atac.var])
if rna.is_view:
L.info("RNA is view")
atac = rna.copy()
if atac.is_view:
L.info("ATAC is view")
atac = atac.copy()

L.info(atac.is_view)


adata_paired = ad.concat([rna.T, atac.T]).T

Expand Down Expand Up @@ -223,14 +234,14 @@
multivi_training_args={}
else:
multivi_training_args = {k: v for k, v in params["multimodal"]['MultiVI']['training_args'].items() if v is not None}

L.info("multivi training args")
print(multivi_training_args)

if params["multimodal"]['MultiVI']['training_plan'] is None:
multivi_training_plan = {}
else:
multivi_training_plan = {k: v for k, v in params["multimodal"]['MultiVI']['training_plan'].items() if v is not None}

L.info("multivi training plan")
print(multivi_training_plan)

mvi.view_anndata_setup()
Expand Down
15 changes: 8 additions & 7 deletions panpipes/python_scripts/plot_umaps_batch_correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# cmap_choice = "BuPu" # previous default = "viridis"
bupu = cm.get_cmap('BuPu', 512)
cmap_choice= ListedColormap(bupu(np.linspace(0.1, 1, 256)))
dpi_use = 400 # previous default of 300 made the plots look blurry with high cell numbers (200k+)


# load metadata
Expand Down Expand Up @@ -87,7 +88,7 @@
os.mkdir(os.path.join(args.fig_dir, mod))
L.info("plotting modality: %s" % mod)
plt_df = umaps_df[umaps_df['mod'] == mod].copy()
pointsize = 10000 / plt_df.shape[0]
pointsize = 100000 / plt_df.shape[0]
plt_df["method"] = plt_df["method"].astype("category")
# put none at the top of the list
if mod != "multimodal":
Expand All @@ -113,11 +114,11 @@
#plt_df = plt_df.sort_values(by="umap_1")
g = sns.FacetGrid(plt_df, col="method", col_wrap=3, sharex=False, sharey=False)
g = (g.map(sns.scatterplot, "umap_1", "umap_2", col, s=pointsize, linewidth=0))
g.add_legend()
plt.legend(loc = 'center left', bbox_to_anchor = (1, 0.5), markerscale = 20)
g.savefig(os.path.join(args.fig_dir, mod, "umap_method_" + str(col) + ".png"))
fig, ax = batch_scatter_two_var(plt_df, "method", col, palette_choice=palette_choice)
if fig is not None:
fig.savefig(os.path.join(args.fig_dir, mod, "umap_method_facet_" + str(col) + ".png"), dpi=300)
fig.savefig(os.path.join(args.fig_dir, mod, "umap_method_facet_" + str(col) + ".png"), dpi=dpi_use)
plt.clf()

ncats = len(plt_df['method'].unique())
Expand Down Expand Up @@ -165,7 +166,7 @@
cbar_ax = fig.add_axes([0.85, 0.35, 0.025, 0.35])
fig.colorbar(im, cbar_ax)
fig.suptitle(qc)
plt.savefig(os.path.join(args.fig_dir, mod , "umap_method_" + qc + ".png"), dpi = 300)
plt.savefig(os.path.join(args.fig_dir, mod , "umap_method_" + qc + ".png"), dpi = dpi_use)
plt.clf()
else:
# this is a categorical colored plot
Expand All @@ -174,10 +175,10 @@
L.info("plotting qc var (categorical) %s"%qc)
g = sns.FacetGrid(plt_df, col="method", col_wrap=3, sharex=False, sharey=False)
g = (g.map(sns.scatterplot, "umap_1", "umap_2", qc, s=pointsize, linewidth=0))
g.add_legend()
g.savefig(os.path.join(args.fig_dir, mod, "umap_method_" + qc + ".png"), dpi = 300)
plt.legend(loc = 'center left', bbox_to_anchor = (1, 0.5), markerscale = 20)
g.savefig(os.path.join(args.fig_dir, mod, "umap_method_" + qc + ".png"), dpi = dpi_use)
plt.clf()
else:
L.info('skipping plot as too many categorys %s' % qc )
L.info('skipping plot as too many categories %s' % qc )

L.info('done')
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ spatial = [
"cell2location",
"tangram-sc"
]

multivipatch = [
"scvi-tools<=0.20.3",
"requests"
]
[project.scripts]
panpipes = "panpipes:entry.main"

Expand Down

0 comments on commit 3f3c17b

Please sign in to comment.