Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting genomic coordinates of differential features #10

Open
cgirardot opened this issue Oct 27, 2020 · 17 comments
Open

Extracting genomic coordinates of differential features #10

cgirardot opened this issue Oct 27, 2020 · 17 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@cgirardot
Copy link

Dear chesser,

I am using the code in example_analysis.ipynb to learn where the differential regions are. I am not really a python guy and would appreciate if you could help me to solve the following issues:

  1. the script currently plot (at the end) 3 matrices. The 2 first one are OK to visualize the TAD structures but the scale is often not adapted to loop visualisation. I'd like to replace the HiC signal with the observed/exp value in the first 2 matrices; but I don t know how to do this. The matrices I am loading are fanc hic matrices.

  2. the script has a commented margin that I believe would allow to increase the visualized region. It is a great idea for the smaller regions and I would like to use this. Unfortunately, when I uncomment the code, the squares (corresponding to the extracted regions) are completely off. Could you help having a version of the script working with the margin ?

Thank you !

@kaukrise
Copy link
Collaborator

Hi,

please have a look at the documentation for FAN-C, where you can find detailed descriptions of the plotting API, which I think is going to be very useful in addressing your questions: https://fan-c.readthedocs.io/en/latest/api/plot.html

If you feel like this may be beyond your expertise, feel free to contact the Vaquerizas lab to enquire about a possible collaboration: https://www.vaquerizaslab.org/contact/

@cgirardot
Copy link
Author

OK. I thought having the margin working in your demo script would be of general interest. I'll check the docs to find out how to get the OE from the matrix. I also assumed it was an easy one for you. Sorry for bothering. Thank you.

@cgirardot cgirardot reopened this Oct 28, 2020
@cgirardot
Copy link
Author

sorry I closed this too fast.
Reading the fanc doc, I managed to plot what I want wrt point 1 above. But I am still trying to understand how I can add margin when the window size is smaller to improve the display. I can't find information on the format of eg gained_features.tsv. Could you please hint?

@nickmachnik
Copy link
Collaborator

Hi @cgirardot!
Do I understand correctly that you want to plot a large region (larger than a single window in your chess sim run) and display all the rectangles for the extracted features in that?
If yes, then I am sorry to say that we currently have no code for that. The right person to help here is @sgalan, but for now maybe I can provide some information that will help: in gained_features.csv each row corresponds to a single rectangle, i.e. a single feature extracted. The first columns are, in that order:

  • the pair id (same as the first column in the chess sim output) of the region the feature is in
  • an id for that specific feature
  • x max
  • x min
  • y max
  • y min, which are the four corners of the rectangle marking the feature in the region matrix.

In order to plot these rectangles at the correct positions in a larger matrix (e.g. with margins), the x and y coordinates have to be transformed. I don't know how to do this at the moment. If @sgalan has no easy solution I will mark this as requested enhancement and place it on our to-do list.
I hope that helps a bit, good luck!

@nickmachnik
Copy link
Collaborator

nickmachnik commented Oct 28, 2020

@cgirardot , also thanks for pointing out that the information about the columns is missing in the docs, have added this.

@nickmachnik nickmachnik added the enhancement New feature or request label Nov 2, 2020
@cgirardot
Copy link
Author

I am a bit confused with the formats. Let s take an example.

After cross-correlation, I have (in subregions_4_clusters_lost):

Screenshot 2020-11-05 at 18 04 23

So I should look in "lost_features" for the feature IDs 20 to 23 :

Screenshot 2020-11-05 at 18 06 34

And here is a view on this region :

Screenshot 2020-11-05 at 18 07 14

we are looking at the blue boxes in the middle plot.

  1. why do I have only 2 rectangles but 4 features in the lost_features file? My guess is it is because it is symmetrical ?
  2. Are the coordinates in lost_features in "bins" ? The region on display is chr3L:80000002-10000001, what is the easy way to extract the regions involved in e.g. feature 20? I am sure it is too late and I am missing the obvious here.

@sgalan
Copy link
Collaborator

sgalan commented Nov 6, 2020 via email

@cgirardot
Copy link
Author

Hi @sgalan
thanks for the confirmation. Could you also hint on the last question, which is the most important to move on for me. If you look at the data and images above: how can I extract the coordinates of regions involved in e.g. feature 20?
thx

@sgalan
Copy link
Collaborator

sgalan commented Nov 9, 2020 via email

@PerrineLacour
Copy link

Hello @sgalan ,

I am a bit confused with the formula you provided. For example with the loops found in @cgirardot 's data, the x and y coordinates of the rectangle don't refer to the genomic regions that interact (the x and y are on a horizontal and vertical axes while the interaction is between two regions found by following the diagonals).

How can we get the coordinates of the regions involved in the loop?

Best,

Perrine

@PerrineLacour
Copy link

I realised that my previous comment may be unclear.
To be more precise, I have read the code regarding extracting the features and it seems to me that you scale (zoom clipped) and rotate the matrix before looking for the features. Is that correct?
If it is the case, it would explain why the x coordinates of symmetric features are the same (while x and y coordinates should be reversed between symmetric features in the original matrix), and also why the feature areas are rectangles and not diamond-shaped as it is usually the case in HiC matrices (especially the TADs).

If I understood the code correctly, it also means that the x and y coordinates retrieved from the gained and lost files do not correspond to the regions involved in the loop, but rather to the coordinates of the feature on the picture.

Is it correct?

Best,

Perrine

@cgirardot
Copy link
Author

@sgalan I was wondering if you could comment on @PerrineLacour questions?

@sgalan
Copy link
Collaborator

sgalan commented Nov 20, 2020 via email

@cgirardot
Copy link
Author

Hi @sgalan thank you for your answer.

I understand that this is going to be a general issue for a lot of people i.e. it is not so trivial to understand. Don't you also have the same issue when analyzing data for your own papers?
If so, would you be so nice to share in the chess package a script allowing to retrieve the regions involved in a given extracted feature like a loop?

Thanks a million for your time and patience

@sgalan
Copy link
Collaborator

sgalan commented Nov 22, 2020 via email

@jvaquerizas
Copy link

Hi @BenxiaHu,

This is really not appropriate language to use to ask for someone to implement a software feature for you.

@ALL, as Silvia mentioned above, the current reported location of the feature corresponds to the actual position of the feature on the matrix, rather than the genomic coordinates of the feature. This is implemented as such in this version of the software since which coordinates to report can heavily depend on the type of feature being detected (eg, TAD, stripe, loop). This makes it difficult to come up with a default approach for which genomic coordinates to report. For the time being, you can use Silvia's explanation above to compute these coordinates yourself. We will review the documentation and include further guidance if necessary.

In addition, we always encourage potential contributors to write pull requests with features of interest, so we can review the, and incorporate in an updated if appropriate.

I hope that helps.

Best,
Juanma Vaquerizas

your answer really does not mean anything.

what we want is just to retrieve the genemoe coordinates based on gained/lost features.

Do you understand our question?

@nickmachnik nickmachnik added the good first issue Good for newcomers label Nov 22, 2020
@vaquerizaslab vaquerizaslab locked and limited conversation to collaborators Nov 22, 2020
@vaquerizaslab vaquerizaslab unlocked this conversation Nov 22, 2020
@nickmachnik nickmachnik changed the title example_analysis.ipynb Extracting genomic coordinates of differential features Nov 22, 2020
@nickmachnik
Copy link
Collaborator

I marked this as 'good first issue'; if we find time for this we might implement this ourselves, but as Juanma said, pull requests with solutions are more than welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants