scverse / muon

muon is a multimodal omics Python framework
https://muon.scverse.org/
BSD 3-Clause "New" or "Revised" License
211 stars 30 forks source link

Add fragment file path to a merged mudata object #133

Open jolvhull opened 7 months ago

jolvhull commented 7 months ago

Dear muon-team,

I have converted my scATAC-seq SeuratObject to a mudata object but the information on the fragments files does not seem to be transferred. mdata.uns is empty. My object is a merged object of multiple samples that each have a separate fragment file. I tried to run muon.atac.tl.locate_fragments by doing this for each subset in the object: """" samples = ['sample1', 'sample2', 'sample3'] fragment_dict = { 'sample1': os.path.join(work_dir, 'data/sample1_atac_fragments.tsv.gz), sample2': os.path.join(work_dir, 'data/sample2_atac_fragments.tsv.gz), sample3': os.path.join(work_dir, 'data/sample3_atac_fragments.tsv.gz)}

for x in samples: muon.atac.tl.locate_fragments(mdata[mdata.obs.sample == x], fragments_dict[x]) """"

However, when I then try to continue with my QC, I still get the error "There is no fragments file located yet. Run muon.atac.tl.locate_fragments first."

When I subset my data, run muon.atac.tl.locate_fragments(sample1, fragments_dict['sample1']) I am able to continue with QC (nucleosome signal)

How can I add the fragment file location for my complete dataset, where each subset, based on the value in an obs column, has its own fragment file?

Thank you!

gtca commented 5 months ago

Hey @jolvhull,

If I understand the context correctly, the line mdata[mdata.obs.sample == x] returns a view into the part of the MuData object. You can read more about views vs copies here.

The views are read-only by definition, and the underlying data for the three samples would be the same in this case.

What we can do is to add a warning to the locate_fragments() function when the input is a view.