Skip to content

Commit

Permalink
add vpt parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahOuologuem committed Nov 7, 2024
1 parent cb16526 commit 24f035a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 38 deletions.
63 changes: 41 additions & 22 deletions panpipes/funcs/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,40 +157,58 @@ def gen_load_spatial_jobs(caf, mode_dictionary = {}, load_raw=True):
else:
spatial_path = caf["spatial_path"][nn]
if caf['spatial_filetype'][nn]=="vizgen":
spatial_counts = None
spatial_fullres_image_file = None
spatial_tissue_positions_file = None
spatial_scalefactors_file = None
visium_feature_bc_matrix = None
visium_fullres_image_file = None
visium_tissue_positions_file = None
visium_scalefactors_file = None
spatial_filetype = caf['spatial_filetype'][nn]
if pd.notna(caf['vpt_cell_by_gene'][nn]):
vpt_cell_by_gene = caf['vpt_cell_by_gene'][nn]
else:
vpt_cell_by_gene = None
if pd.notna(caf['vpt_cell_metadata'][nn]):
vpt_cell_metadata = caf['vpt_cell_metadata'][nn]
else:
vpt_cell_metadata = None
if pd.notna(caf['vpt_cell_boundaries'][nn]):
vpt_cell_boundaries = caf['vpt_cell_boundaries'][nn]
else:
vpt_cell_boundaries = None
elif caf['spatial_filetype'][nn]=="visium":
vpt_cell_by_gene = None
vpt_cell_metadata = None
vpt_cell_boundaries = None
spatial_filetype = caf['spatial_filetype'][nn]
#counts file
if pd.notna(caf["spatial_counts"][nn]):
spatial_counts= caf["spatial_counts"][nn]
if pd.notna(caf["visium_feature_bc_matrix"][nn]):
visium_feature_bc_matrix= caf["visium_feature_bc_matrix"][nn]
else:
spatial_counts = None
visium_feature_bc_matrix = None
# fullres image
if pd.notna(caf["spatial_fullres_image_file"][nn]):
spatial_fullres_image_file= caf["spatial_fullres_image_file"][nn]
if pd.notna(caf["visium_fullres_image_file"][nn]):
visium_fullres_image_file= caf["visium_fullres_image_file"][nn]
else:
spatial_fullres_image_file = None
visium_fullres_image_file = None
# tissue position
if pd.notna(caf["spatial_tissue_positions_file"][nn]):
spatial_tissue_positions_file= caf["spatial_tissue_positions_file"][nn]
if pd.notna(caf["visium_tissue_positions_file"][nn]):
visium_tissue_positions_file= caf["visium_tissue_positions_file"][nn]
else:
spatial_tissue_positions_file = None
visium_tissue_positions_file = None
# scalefactor
if pd.notna(caf["spatial_scalefactors_file"][nn]):
spatial_scalefactors_file= caf["spatial_scalefactors_file"][nn]
if pd.notna(caf["visium_scalefactors_file"][nn]):
visium_scalefactors_file= caf["visium_scalefactors_file"][nn]
else:
spatial_scalefactors_file = None
visium_scalefactors_file = None
else:
spatial_path= None
spatial_filetype = None
spatial_counts = None
spatial_fullres_image_file = None
spatial_tissue_positions_file = None
spatial_scalefactors_file = None
visium_feature_bc_matrix = None
visium_fullres_image_file = None
visium_tissue_positions_file = None
visium_scalefactors_file = None
vpt_cell_by_gene = None
vpt_cell_metadata = None
vpt_cell_boundaries = None

if 'barcode_mtd_path' in caf.columns:
cell_mtd_path = caf['barcode_mtd_path'][nn] #not yielding this right now!
Expand All @@ -204,8 +222,9 @@ def gen_load_spatial_jobs(caf, mode_dictionary = {}, load_raw=True):
outfile = outfile + ".zarr"
sample_id = caf['sample_id'][nn]

yield spatial_path, outfile, \
sample_id, spatial_filetype, spatial_counts, spatial_fullres_image_file, spatial_tissue_positions_file, spatial_scalefactors_file
yield spatial_path, outfile, sample_id, spatial_filetype, \
visium_feature_bc_matrix, visium_fullres_image_file, visium_tissue_positions_file, visium_scalefactors_file, \
vpt_cell_by_gene, vpt_cell_metadata, vpt_cell_boundaries


def read_anndata(
Expand Down
37 changes: 21 additions & 16 deletions panpipes/panpipes/pipeline_qc_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,25 @@ def gen_load_spatial_anndata_jobs():
@follows(mkdir("tmp"))
@files(gen_load_spatial_anndata_jobs)
def load_mudatas(spatial_path, outfile,
sample_id, spatial_filetype, spatial_counts,
spatial_fullres_image_file, spatial_tissue_positions_file, spatial_scalefactors_file):
sample_id, spatial_filetype, visium_feature_bc_matrix, visium_fullres_image_file, visium_tissue_positions_file, visium_scalefactors_file,
vpt_cell_by_gene, vpt_cell_metadata, vpt_cell_boundaries):

path_dict = {'spatial':spatial_path}

print(path_dict)
print('sample_id = %s' % str(sample_id))
print('outfile = %s' % str(outfile))
print('spatial_filetype = %s' % str(spatial_filetype))
#print('spatial_counts = %s' % str(spatial_counts))
#if spatial_filetype == "vizgen":
# print('spatial_metadata = %s' % str(spatial_metadata))
# print('spatial_transformation = %s' % str(spatial_transformation))
#else:
# print("visium")

if spatial_filetype == "visium":
print('spatial_counts = %s' % str(spatial_counts))
print('spatial_fullres_image_file= %s' % str(spatial_fullres_image_file))
print('spatial_tissue_positions_file= %s' % str(spatial_tissue_positions_file))
print('spatial_scalefactors_file= %s' % str(spatial_scalefactors_file))
print('visium_feature_bc_matrix = %s' % str(visium_feature_bc_matrix))
print('visium_fullres_image_file= %s' % str(visium_fullres_image_file))
print('visium_tissue_positions_file= %s' % str(visium_tissue_positions_file))
print('visium_scalefactors_file= %s' % str(visium_scalefactors_file))
if spatial_filetype == "vizgen":
print('vpt_cell_by_gene = %s' % str(vpt_cell_by_gene))
print('vpt_cell_metadata= %s' % str(vpt_cell_metadata))
print('vpt_cell_boundaries= %s' % str(vpt_cell_boundaries))
modality_dict = {k:True if path_dict[k] is not None else False for k,v in {'spatial': True}.items() }
print(modality_dict)

Expand All @@ -109,10 +108,16 @@ def load_mudatas(spatial_path, outfile,
"""
if spatial_filetype == "visium":
cmd += """
--spatial_counts %(spatial_counts)s
--scalefactors_file %(spatial_scalefactors_file)s
--fullres_image_file %(spatial_fullres_image_file)s
--tissue_positions_file %(spatial_tissue_positions_file)s
--visium_feature_bc_matrix %(visium_feature_bc_matrix)s
--scalefactors_file %(visium_scalefactors_file)s
--fullres_image_file %(visium_fullres_image_file)s
--tissue_positions_file %(visium_tissue_positions_file)s
"""
if spatial_filetype == "vizgen":
cmd += """
--vpt_cell_by_gene %(vpt_cell_by_gene)s
--vpt_cell_metadata %(vpt_cell_metadata)s
--vpt_cell_boundaries %(vpt_cell_boundaries)s
"""
cmd += " > logs/1_make_mudatas_%(sample_id)s.log"
job_kwargs["job_threads"] = PARAMS['resources_threads_medium']
Expand Down

0 comments on commit 24f035a

Please sign in to comment.