Skip to content

Commit

Permalink
disable new hashing methods + add mudata
Browse files Browse the repository at this point in the history
  • Loading branch information
wxicu committed Nov 12, 2023
1 parent 4155572 commit 688770b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
49 changes: 49 additions & 0 deletions bin/summary_gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def demuxlet_summary(demuxlet_res, raw_adata, raw_mudata):
adata.write("genetic_summary/adata/adata_with_"+os.path.basename(x)+".h5ad")
assign.append(demuxlet_assign)

if raw_mudata is not None:
mudata = raw_mudata.copy()
mudata['rna'].obs = mudata['rna'].obs.merge(demuxlet_assign, left_index=True, right_on='Barcode', how='left').set_index('Barcode')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("genetic_summary/mudata/mudata_with_"+ os.path.basename(x)+".h5mu")

params_dir = os.path.join(x, [filename for filename in os.listdir(x) if filename.endswith("params.csv")][0])
params_res = pd.read_csv(params_dir, keep_default_na=False, index_col=0)
params_res.columns = [os.path.basename(x)]
Expand Down Expand Up @@ -80,6 +89,16 @@ def freemuxlet_summary(freemuxlet_res, raw_adata, raw_mudata):
adata.obs.donor = adata.obs.donor.fillna("negative")
adata.obs.donor = adata.obs.donor.astype(str)
adata.write("genetic_summary/adata/adata_with_"+ os.path.basename(x)+".h5ad")

if raw_mudata is not None:
mudata = raw_mudata.copy()
mudata['rna'].obs = mudata['rna'].obs.merge(freemuxlet_assign, left_index=True, right_on='Barcode', how='left').set_index('Barcode')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("genetic_summary/mudata/mudata_with_"+ os.path.basename(x)+".h5mu")

assign.append(freemuxlet_assign)

params_dir = os.path.join(x, [filename for filename in os.listdir(x) if filename.endswith("params.csv")][0])
Expand Down Expand Up @@ -120,6 +139,16 @@ def souporcell_summary(souporcell_res, raw_adata, raw_mudata):
adata.obs.donor = adata.obs.donor.fillna("negative")
adata.obs.donor = adata.obs.donor.astype(str)
adata.write("genetic_summary/adata/adata_with_"+ os.path.basename(x)+".h5ad")

if raw_mudata is not None:
mudata = raw_mudata.copy()
mudata['rna'].obs = mudata['rna'].obs.merge(obs_res, left_index=True, right_on='Barcode', how='left').set_index('Barcode')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("genetic_summary/mudata/mudata_with_"+ os.path.basename(x)+".h5mu")

assign.append(obs_res)

params_dir = os.path.join(x, [filename for filename in os.listdir(x) if filename.endswith("params.csv")][0])
Expand Down Expand Up @@ -160,6 +189,16 @@ def vireo_summary(vireo_res, raw_adata, raw_mudata):
adata.obs.donor = adata.obs.donor.fillna("negative")
adata.obs.donor = adata.obs.donor.astype(str)
adata.write("genetic_summary/adata/adata_with_"+ os.path.basename(x)+".h5ad")

if raw_mudata is not None:
mudata = raw_mudata.copy()
mudata['rna'].obs = mudata['rna'].obs.merge(obs_res, left_index=True, right_on='Barcode', how='left').set_index('Barcode')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("genetic_summary/mudata/mudata_with_"+ os.path.basename(x)+".h5mu")

assign.append(obs_res)

params_dir = os.path.join(x, [filename for filename in os.listdir(x) if filename.endswith("params.csv")][0])
Expand Down Expand Up @@ -198,6 +237,16 @@ def scsplit_summary(scsplit_res, raw_adata, raw_mudata):
adata.obs.donor = adata.obs.donor.fillna("negative")
adata.obs.donor = adata.obs.donor.astype(str)
adata.write("genetic_summary/adata/adata_with_"+ os.path.basename(x)+".h5ad")

if raw_mudata is not None:
mudata = raw_mudata.copy()
mudata['rna'].obs = mudata['rna'].obs.merge(obs_res, left_index=True, right_on='Barcode', how='left').set_index('Barcode')
mudata['rna'].obs.rename(columns={mudata['rna'].obs.columns[0]: 'donor'}, inplace=True)
mudata['rna'].obs.donor = mudata['rna'].obs.donor.fillna("negative")
mudata['rna'].obs.donor = mudata['rna'].obs.donor.astype(str)
mudata.update()
mudata.write("genetic_summary/mudata/mudata_with_"+ os.path.basename(x)+".h5mu")

assign.append(obs_res)

params_dir = os.path.join(x, [filename for filename in os.listdir(x) if filename.endswith("params.csv")][0])
Expand Down
6 changes: 3 additions & 3 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ params {
filter_demuxem = "True"

// gmm-demux
gmmDemux = "True"
gmmDemux = "False"
hto_matrix_gmm_demux = "filtered"
assignmentOutGmmDemux = "gmm_demux"
hto_name_gmm = "None"
Expand All @@ -136,7 +136,7 @@ params {
ambiguous = 0.05

// demuxmix
demuxmix = "True"
demuxmix = "False"
rna_matrix_demuxmix = "raw"
hto_matrix_demuxmix = "raw"
assignmentOutDemuxmix = "demuxmix"
Expand All @@ -152,7 +152,7 @@ params {
k_rna = 1.5

// bff
bff = "True"
bff = "False"
rna_matrix_bff = "raw"
hto_matrix_bff = "raw"
assignmentOutBff = "bff"
Expand Down

0 comments on commit 688770b

Please sign in to comment.