theMILOlab / SPATA2

A Toolbox for Spatial Transcriptomics Analysis
https://themilolab.github.io/SPATA2/
105 stars 17 forks source link

Error in infercnv:::plot_cnv #43

Closed aapetti closed 2 months ago

aapetti commented 2 years ago

Thank you for developing SPATA! I just started using it to explore some Visium V1 data, and encountered an error in infercnv:::plot_cnv. I used initiateSpataObject_10X to perform the initial analysis steps, then ran runCnvAnalysis. The analysis appeared to be proceeding, and the inferCNV object was created and saved, but I encountered an error in plot_cnv. The last few lines of the function output are below. Note that the @cnv slot in my spata object is an empty list, and the @expr.data slot in my inferCNV object is also an empty list.

Last few lines of the runCnvAnalysis output:

12:14:15 Copy number variation pipeline completed. 12:14:15 Saving infercnv-object under 'spata2.sct.cnv/infercnv-obj.RDS'. 12:14:29 Plotting results. Attempting to call function 'infercnv:::plot_cnv()' with specified parameters failed with the following error message: Error in .fn(infercnv_obj = 1, out_dir = 2, k_obs_groups = 3, cluster_by_groups = 4, : trying to get slot "expr.data" from an object of a basic class ("list") with no slots

12:14:29 infercnv:::plot_cnv() failed. Attempting to plot with default setting. 12:14:29 inferncnv::plot_cnv() failed with default setting, too. 12:14:29 The infercnv-object has been saved under 'spata2.sct.cnv/infercnv-obj.RDS'.Please try to plot the heatmap manually. 12:14:29 If the error in infercnv:::plot_cnv() persists, consider to open an issue at https://github.com/theMILOlab/SPATA2/issues. Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'spata2.sct.cnv/infercnv.outliers_removed.observations.txt': No such file or directory

Any help with this error, or with further diagnosis, would be much appreciated. Please let me know if I need to provide further information.

Thank you!

Allegra Petti

kueckelj commented 2 years ago

Hello aapetti, can you post a picture/screenshot of the executed command and the messages that are printed in the console? Does the same error appear with other spata2 objects?

aapetti commented 2 years ago

Thanks for replying! I've pasted the script below, and attached a screenshot of the output. I have only tried SPATA using this sample, but I tested other normalization pipelines with this data and the error occurred repeatedly.

# try SPATA for CNV analysis

library("Seurat")
library("SPATA2")
library("infercnv")

setwd("/Users/Allegra/Dropbox/WUSM/SpatialTranscriptomics/Spatial/SPATA");
indir = "/Users/Allegra/Dropbox/WUSM/SpatialTranscriptomics/Spatial/Visium_Batch4_FFPE_9_2021"

sample ="TWBK-ST073021-4"
outdir = "spata2.out" # creates a subdir of the working directory
outdir_cnv = "spata2.cnv"

slice4 <- initiateSpataObject_10X(
   directory_10X = indir,
   sample_name = "ST073021.4",
   directory_spata = outdir,
   directory_seurat = NULL,
   combine_with_wd = "/",
   gene_set_path = NULL,
   SCTransform = FALSE,
   NormalizeData = TRUE,
   FindVariableFeatures = TRUE,
   ScaleData = TRUE,
   RunPCA = list(npcs = 60),
   FindNeighbors = list(dims = 1:30),
   FindClusters = list(resolution = 0.8),
   RunTSNE = TRUE,
   RunUMAP = list(dims = 1:30),
   verbose = TRUE
 )

 slice4 <- runCnvAnalysis(
     object = slice4,
     directory_cnv_folder = outdir_cnv, 
     cnv_prefix = "Chr"
   )
SPATA_screenshot
kueckelj commented 2 years ago

I am aware of that error as it has happened to me, too. Although I don't know what exactly the problem is. I can not reproduce it. The problem is that it is caused from within the infercnv package which I don't have access to.

Do you have other Visium samples? If so, does the same error message appear if you use cnv analysis with them?

dfeng4127 commented 1 year ago

have you solve the problem yet? I got the same problem too.

aapetti commented 1 year ago

No, I have not solved the problem. I got the same error with every sample I tried. Other copy number calling tools (e.g. CONICSmat) work well with Visium data, so I did not feel it was worth the time/effort to troubleshoot this tool.

dfeng4127 commented 1 year ago

No, I have not solved the problem. I got the same error with every sample I tried. Other copy number calling tools (e.g. CONICSmat) work well with Visium data, so I did not feel it was worth the time/effort to troubleshoot this tool.

ok,thanks for your advice

simonmfr commented 2 months ago

This should be resolved along with our update to SPATA2 v3. In case this is still of interest, please feel free to re-try using the new CNV analysis tutorial.