broadinstitute / infercnv

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

The dendrogram is strange in infer1.14.0 #521

Open LeeWang21 opened 1 year ago

LeeWang21 commented 1 year ago

Hi, I used inferCNV 1.14.0 to infer the copy number variationsof two datasets. However, the dendrogram on the left panel looks strange. when I use the old version inferCNV1.6, everything goes well. How can I fix it to normal dendrogram? thanks

here is the code for infercnv::run

all_samples_integrated_epi_imm_anno_res_0.3_object <- infercnv::run(all_samples_integrated_epi_imm_anno_res_0.3_object, cutoff = 0.05, out_dir = "/public/home/analysis/infercnv/infercnv_1.14_epi_imm_res0.3", cluster_by_groups = T, HMM = F, denoise = T, sd_amplifier = 1.5, plot_steps = F, cluster_references = T) The final arguments

strange_dendrogram_1 strange_dendrogram_2 normal_dendrogram_1 infercnv_1 14 0 infercnv_1 6 0
GeorgescuC commented 1 year ago

Hi @LeeWang21 ,

When the dendrogram looks this way in the new version, the issue is the leiden_resolution parameter being too high, which results in very high fragmentation of subclusters. You should try lowering it to 0.005 or lower, depending on your data. If you update to the latest version (1.14.2) an new plot will also be generated after subclustering that shows the subclusters so you can figure out if the resolution is good for your data.

Regards, Christophe.

Dana11T commented 1 year ago

@GeorgescuC Hello, my inercnv is the latest version 1.14.2, I saw the sub-clustering diagram you mentioned, I would like to ask, if I want to use this clustering result to define malignant cells, then the information of the clustering result I In which file should it be found. In addition, this clustering result still needs a period of time for me to get used to.Where do I need to set leiden_resolution=0.005 to redraw the graph if I want to go back to the original clustering results.

GeorgescuC commented 1 year ago

Hi @Dana11T ,

The current latest version of infercnv is 1.16.0, which has some fixes and improvements to visualize subclusters.

If you want to use a given set of subclusters, you can get them from the infercnv object that is returned from the run, or reload it from the output folder. Here's an example with reloading the results from the output folder:

# reload the results
infercnv_results = readRDS("output_dir/run.final.infercnv_obj")

# list of hclust objects, one per annotation
infercnv_results@tumor_subclusters$hc

# list (one element per annotation) of lists (one element per subcluster) of cells in each subcluster
infercnv_results@tumor_subclusters$subclusters

The leiden_resolution parameter can be set in the run() method call, and if you have already run infercnv in the same output directory with the same data, steps that have already been processed and are not impacted by options that have been changed won't need to be rerun.

If you want to test different leiden resolutions while conserving older results, one thing you can do is to copy the whole output folder in which you ran infercnv the first time, and use the copied folder for your 2nd run. This way the steps before the subclustering don't need to be rerun, and you still have a copy of your original run to go back to if you want.

infercnv_obj = CreateInfercnvObject(...)

infercnv_run1 = infercnv::run(infercnv_obj, out_dir="run1_0.05", leiden_resolution=0.05, ...)

# copy "run1_0.5" to a folder "run2"

infercnv_run2 = infercnv::run(infercnv_obj, out_dir="run2_0.005", leiden_resolution=0.005, ...)

Regards, Christophe.