open2c / coolpuppy

A versatile tool to perform pile-up analysis on Hi-C data in .cool format.
MIT License
77 stars 11 forks source link

No chromosomes are in common between the coordinate file and the cooler file. #151

Closed ratheraarif closed 2 months ago

ratheraarif commented 2 months ago

Thank you for making such wonderful tool.

when I try to execute the following code pup = coolpup.pileup(clr_MT, cenI_vs_all, features_format='bedpe', local = False, flank=flank, min_diag=0)

ValueError: No chromosomes are in common between the coordinate file and the cooler file. Are they in the same format, e.g. starting with "chr"?

please note that the chromosome names are however same

> clr_MT.chromnames gives ['chrI', 'chrII', 'chrIII', 'chrIV', 'chrV', 'chrVI', 'chrVII', 'chrVIII', 'chrIX', 'chrX', 'chrXI', 'chrXII', 'chrXIII', 'chrXIV', 'chrXV', 'chrXVI', 'chrM']

and the cenI_vs_all looks like

image

cooltools.__version__ is '0.7.0' bioframe.__version__ is 0.4.1

I also tried with local= True but it still does not work.

please note that I am actually interested in doing pileup of how centromere of chr1 interacts with all other centromeres.

I also tried the same in cooltools with stack_WT = cooltools.pileup(clr_WT, cenI_vs_all, view_df=chr_arms, expected_df=expected_WT, flank=flank) mtx_WT = np.nanmean(stack_WT, axis=0) it generates a matrix of all Nans

efriman commented 2 months ago

Hi. If you want to do cross-chromosomal you have to specify trans=True. Please see tutorial https://coolpuppy.readthedocs.io/en/latest/Examples/Walkthrough_API.html#trans-inter-chromosomal-pileups

ratheraarif commented 2 months ago

Thank you for the quick reply. I tried to run the following code pup = coolpup.pileup(clr_MT, pairs, features_format='bedpe', expected_df=trans_expected_MT, trans=True, flank = 5000, rescale=True, rescale_flank=1, rescale_size=99) and plotted the output as

fg = plotpup.plot(pup, score=True, cmap='coolwarm', scale='log', sym=True, vmax=100, height=3) and the plot is shown as

image

However, I expect the plot to look like this

image

This plot shows the average interaction of centromere centromere interaction. Am I missing anything here

efriman commented 2 months ago

Can you try it with rescale=False

ratheraarif commented 2 months ago

setting rescale =False seems to work but not as expected. the output now looks like:

image

please note that I ran the following code:

trans_expected_MT = expected_trans( clr_MT, chunksize=1000000)

pup_MT = coolpup.pileup(clr_MT, pairs, features_format='bedpe', trans=True, expected_df=trans_expected, flank = 10000, rescale=False)

fg = plotpup.plot(pup_MT, score=True, cmap='coolwarm', scale='log', sym=True, vmin = 100, height=2)

Do I need to change any additional settings.

Phlya commented 2 months ago

Are you sure flank=10000 is reasonable? The whole pileup is enriched, relative to expected, so perhaps you need a much larger flank to see it as a spot?

ratheraarif commented 2 months ago

Oh I see. I needed to increase the flank size and it's working as expected. Thank you!

ratheraarif commented 2 months ago

@Phlya @efriman I was wondering if it's possible to know the contribution of each snippet to the final plot. I want to find out how each centro centro interaction( for instance chrI with all other, chrII with all other and the like) contributed to the final enrichment and plot that as a histogram. In my opinion I should have 16 different matrices one for each chromosome, so it should be possible. I want to do something Similar to what is shown here( https://coolpuppy.readthedocs.io/en/latest/Examples/TAD_score.html)

efriman commented 2 months ago

You can do groupby=["chrom1", "chrom2"] and then plot with cols and rows if you want per chromosome plots. If you want numbers, you'll have to extract the values from the pileup object, e.g. if you want to take the mean of the center.

ratheraarif commented 2 months ago

thank you! will give it a try