How to create a one chromosome cool matrix #370
-
Hi, I am quite new with the cool format and I am not able to understand how to do this. I have a genome-wide .cool matrix and to perform some analysis I want just a chromosome X .cool matrix. How do I do that? Many thanks Lucía |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
I would also like an answer to lucia's question |
Beta Was this translation helpful? Give feedback.
-
Apologies for not replying to the original question. I am wondering about the reason you need this? You can easily extract just one chromosome from a whole-genome cooler file for analysis. Otherwise, @nvictus would know the best way to do this... It should be straightforward, you just need pixels and bins for the right chromosome, and then use |
Beta Was this translation helpful? Give feedback.
-
Hi @Phlya , well I am trying to analyze my data using FIREcaller: https://yunliweb.its.unc.edu/FIREcaller/download.php |
Beta Was this translation helpful? Give feedback.
-
Looks to me like there's a missing function implementation in the FIREcaller package: If you decide to try hacking the script to use a dataframe or matrix instead of a file, we recently discovered that you can very easily run the Python cooler package from within R using reticulate and extract what you need. In case it helps: reticulate::use_condaenv("myenv") # a conda environment with cooler installed
cooler <- reticulate::import("cooler")
clr <- cooler$Cooler("path/to/file.cool::resolutions/10000")
mat <- clr$matrix(balance = FALSE)$fetch("chr1") # raw counts, unnormalized, as array
dat <- clr$matrix(balance = FALSE, as_pixels = TRUE)$fetch("chr1") # raw counts, unnormalized, as dataframe
|
Beta Was this translation helpful? Give feedback.
-
You know @nvictus , you are so helpful and I want you to know I really appreciate the assistance. Your R code is generating the matrix I think I need for my analysis! One more question, I don't mind using R for sub-setting the .cool file, but does cooler have a CLI command for doing this? |
Beta Was this translation helpful? Give feedback.
-
It sure does! |
Beta Was this translation helpful? Give feedback.
Looks to me like there's a missing function implementation in the FIREcaller package:
cooler2bedpe
.If you decide to try hacking the script to use a dataframe or matrix instead of a file, we recently discovered that you can very easily run the Python cooler package from within R using reticulate and extract what you need. In case it helps: