broadinstitute / infercnv

Inferring CNV from Single-Cell RNA-Seq
Other
557 stars 164 forks source link

altered chromosome order in the heatmap #542

Open veramazzara opened 1 year ago

veramazzara commented 1 year ago

Hi GeorgescuC, thank you for this useful tool! I am working with R version 4.2.3 and infercnv 1.14.2 but I have an issue with the chromosome order; specifically, after creating the infercnv object using the data example except for the gene_order_file I obtain this order in the chromosome

infercnv_object_example <- infercnv::CreateInfercnvObject( raw_counts_matrix=infercnv_data_example, gene_order_file=gene_order_file, annotations_file=infercnv_annots_example, ref_group_names=c("normal"), chr_exclude=c("chrM"))

levels(infercnv_object_example@gene_order$chr) [1] "chr1" "chr2" "chr3" "chr4" "chr5" "chr6" "chr7" "chrX" "chr8" "chr9" "chr11" "chr10" "chr12" "chr13" [15] "chr14" "chr15" "chr16" "chr17" "chr18" "chr20" "chr19" "chr22" "chr21"

Where the order is not correct as expected. I would like to have the classical order chr1, chr2, chr3,…….chrX, chrY. In attachment, the txt file related to the gene_order_file data frame. gene_order_file.txt

I don’t understand the reason of this behaviour, do you have any suggestions to solve this problem?

Thank you so much.

Vera gene_order_file.txt

GeorgescuC commented 1 year ago

Hi @veramazzara ,

The order of the chromosomes on the figure is the order of the chromosomes as first encountered in the gene order file you provide as input, so if you sort the lines in that file according to the order you want, it should sort them in the infercnv figures as well. Currently you gene order file has these lines 15185-15188 where chrX comes after chr7:

VIPR2   chr7    159028175   159144957
PIP5K1P2    chr7    159231435   159233377
PLCXD1  chrX    276322  303356
GTPBP6  chrX    304529  318819

In a terminal, you should be able to fix this by running the following and using the output as gene order file:

sort -k2,2V -k3n -k4n gene_order_file.txt > new_gene_order_file.txt

Regards, Christophe.

veramazzara commented 1 year ago

Hi Christophe, thank you very much for your suggestion!!! Now, all works fine with the order of the chromosomes as I expect.

I did not note the incorrect order of my file, I ordered many times my file but unsuccessfully while with your syntax I resolved the issue!

thank you so much! Best wishes

Vera