Skip to content

Commit

Permalink
New visualization needs
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyMaurer committed Oct 7, 2024
1 parent 6084344 commit a3edbd5
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ spreadsheets/obs.csv
spreadsheets/majorclass/normalized_majorclass_mean_expression_sensitive.csv
spreadsheets/majorclass/raw_majorclass_mean_expression_sensitive.csv
00_raw

[0-9][0-9]_*/

29 changes: 22 additions & 7 deletions scripts/11_Plot_All_Minorclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,32 @@
import seaborn as sns
import os

os.chdir('/project/hipaa_ycheng11lab/atlas/CAMR2024')
os.chdir('/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024/')
os.makedirs('11_Plot_All_Minorclass', exist_ok = True)
sc.settings.n_jobs = -1

adata = ad.read_h5ad('10_Make_Shiny/10_Shiny_Input.h5ad')

resultsPath = "09_Designer_Analysis/PanelOutputV2.txt"
markers = pd.read_csv(resultsPath, sep = '\t') # NOTE: Nrg1 & 2010007h06rik adjusted
resultsPath = "09_Designer_Analysis/PanelDesignerYes.txt"
markers = pd.read_csv(resultsPath, sep = '\t').sort_values(["Major_Name", "Name"]) # NOTE: Nrg1 & 2010007h06rik adjusted
markers = pd.concat([markers.loc[markers["Name"] == markers["Major_Name"], :], markers.loc[markers["Name"] != markers["Major_Name"], :]])
all_d_markers = markers["Marker"].unique().tolist()
# markers["Name"].isin(adata.obs["minorclass"].cat.categories) # mostly false
# markers["Name"].unique().tolist()

#['AC', 'ASTROCYTE', 'ASTROCYTE', 'CONE', 'CONE', 'CONE', 'ENDOTHELIAL', 'ENDOTHELIAL', 'ENDOTHELIAL', 'HC', 'HC', 'MG', 'MG', 'MG', 'MG', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'MICROGLIA', 'RGC', 'RGC', 'RGC', 'ON BC BUT NOT 5D', 'ON BCS (3-6, 13, 15) (6,7, 5A/B/C, 3A', 'UNASSIGNED_BC', '10_NOVEL', '37_NOVEL', '40_M1DUP', '40_M1DUP', '40_M1DUP', '40_M1DUP', '45_ALPHAOFFT', '45_ALPHAOFFT', '7_NOVEL', 'ALPHA-RGC', 'ALPHAOFF-T', 'F-RGC', 'IPRGC', 'IPRGC', 'NOVEL_7']
# ['AC', 'ASTROCYTE', 'CONE', 'ENDOTHELIAL', 'HC', 'MG', 'MICROGLIA', 'RGC', 'ON BC BUT NOT 5D', 'ON BCS (3-6, 13, 15) (6,7, 5A/B/C, 3A', 'UNASSIGNED_BC', '10_NOVEL', '37_NOVEL', '40_M1DUP', '45_ALPHAOFFT', '7_NOVEL', 'ALPHA-RGC', 'ALPHAOFF-T', 'F-RGC', 'IPRGC', 'NOVEL_7']
all_d_names = ['Unassigned_AC', 'Astrocyte', 'Cone', 'Endothelial', 'HC', 'MG', 'Unassigned_Microglia', 'Unassigned_RGC',
'BC3A', 'BC3B', 'BC4', 'BC6', 'BC7', 'BC5A', 'BC5B', 'BC5C',
'Unassigned_BC', '10_Novel', '37_Novel', '40_M1dup', '45_AlphaOFFT', '7_Novel',
'41_AlphaONT', '42_AlphaOFFS', '43_AlphaONS',
'3_FminiON', '4_FminiOFF', '28_FmidiOFF', '38_FmidiON', '32_F_Novel',
'22_M5', '31_M2', '33_M1']


sc.plotting.DotPlot.DEFAULT_SAVE_PREFIX = ""
sc.plotting.DotPlot.DEFAULT_LARGEST_DOT = 200.0
plot_prefix = "/project/hipaa_ycheng11lab/atlas/CAMR2024/11_Plot_All_Minorclass/"
plot_prefix = "/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024/11_Plot_All_Minorclass/"

raw = True
data_string = "normCounts"
Expand All @@ -41,13 +55,14 @@

all_markers = markers["Marker"].unique().tolist()

sc.pl.dotplot(adata[:, all_markers],
var_names = all_markers, gene_symbols = "feature_name",
sc.pl.dotplot(adata[adata.obs["minorclass"].isin(all_d_names), all_d_markers],
var_names = all_d_markers,
gene_symbols = "feature_name", categories_order = all_d_names,
groupby = "minorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}All-Cell_All-Marker_{data_string}.pdf")
save = f"{plot_prefix}All-Cell_All-Marker_{data_string}_vYes.pdf")

exit()

Expand Down
61 changes: 61 additions & 0 deletions scripts/12_photoreceptor_expression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
# coding: utf-8

# In this notebook, we're going plot the mouse retinal data and determine proper marker genes.

import datetime
print(f'{datetime.datetime.now()} Analysis Setup')

import sklearn as sk
import anndata as ad
import scanpy as sc
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
import os

os.chdir('/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024')
os.makedirs('12_photoreceptor_expression', exist_ok = True)
sc.settings.n_jobs = -1

adata = ad.read_h5ad('10_Make_Shiny/10_Shiny_Input.h5ad')


rod_gene = ['Rho','Pde6a', 'Gngt1', 'Optn','Nrl','Nr2e3', 'Reep6', 'Cnga1', 'Guca1b', 'Pde6a', 'Rp1',
'Cngb1','Rcvrn', 'Pdc','Syne2','Mef2c','Fyco1','Atf4']
cone_gene = ['Opn1mw','Opn1sw', 'Ccdc136', 'Optn','Nrl','Gngt2', 'Gnat2']

sc.plotting.DotPlot.DEFAULT_SAVE_PREFIX = ""
sc.plotting.DotPlot.DEFAULT_LARGEST_DOT = 200.0
plot_prefix = "/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024/12_photoreceptor_expression/"

raw = True
data_string = "normCounts"
max_col = 3

for raw in [False, True]:

if raw:
data_string = "rawCounts"
max_col = 12
adata.X = adata.raw.X

# rod_gene = set(rod_gene)
# cone_gene = set(cone_gene)

sc.pl.dotplot(adata[:, rod_gene],
var_names = rod_gene, gene_symbols = "feature_name",
groupby = "majorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}Major-Cell_Rod_{data_string}.pdf")

sc.pl.dotplot(adata[:, cone_gene],
var_names = cone_gene, gene_symbols = "feature_name",
groupby = "majorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}Major-Cell_Cone_{data_string}.pdf")
66 changes: 66 additions & 0 deletions scripts/13_Plot_Ambiguous.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3
# coding: utf-8

# In this notebook, we're going plot the mouse retinal data and determine proper marker genes.

import datetime
print(f'{datetime.datetime.now()} Analysis Setup')

import sklearn as sk
import anndata as ad
import scanpy as sc
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import seaborn as sns
import os

os.chdir('/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024/')
os.makedirs('13_Plot_Ambiguous', exist_ok = True)
sc.settings.n_jobs = -1

adata = ad.read_h5ad('10_Make_Shiny/10_Shiny_Input.h5ad')

resultsPath = "09_Designer_Analysis/PanelDesignV1Ambiguous.txt"
markers = pd.read_csv(resultsPath, sep = '\t') # NOTE: Nrg1 & 2010007h06rik adjusted

sc.plotting.DotPlot.DEFAULT_SAVE_PREFIX = ""
sc.plotting.DotPlot.DEFAULT_LARGEST_DOT = 200.0
plot_prefix = "/project/ycheng11lab/jfmaurer/mouse_retina_atlas_chen_2024/13_Plot_Ambiguous/"

raw = True
data_string = "normCounts"
max_col = 3

for raw in [False, True]:

if raw:
data_string = "rawCounts"
max_col = 12
adata.X = adata.raw.X

all_markers = markers["Marker"].unique().tolist()

sc.pl.dotplot(adata[:, all_markers],
var_names = all_markers, gene_symbols = "feature_name",
groupby = "minorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}Minor-Cell_All-Marker_{data_string}.pdf")

sc.pl.dotplot(adata[:, all_markers],
var_names = all_markers, gene_symbols = "feature_name",
groupby = "majorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}Major-Cell_All-Marker_{data_string}.pdf")

sc.pl.dotplot(adata[adata.obs["majorclass"].isin(["RGC"]), all_markers],
var_names = all_markers, gene_symbols = "feature_name",
groupby = "minorclass",
vmax = max_col,
vmin = 0,
show = False,
save = f"{plot_prefix}Minor-Cell_All-Marker_{data_string}_RGC.pdf")

0 comments on commit a3edbd5

Please sign in to comment.