theMILOlab / SPATA2

A Toolbox for Spatial Gene Expression Analysis
77 stars 15 forks source link

initiateSpataObject_10X Error #98

Closed BaluPai closed 4 months ago

BaluPai commented 5 months ago
          Hi @simonmfr This is my dummy code.

i <- 1 my_SP <- initiateSpataObject_10X(directory_10X = paste("/Users/ayushbharati/Dropbox/PAH_visium/2ndorder/Spaceranger/RL_A",i,"_S1/outs",sep = ""), sample_name = paste("ph",i,sep = ""))

and this is the error

image

Originally posted by @ayushbharati in https://github.com/theMILOlab/SPATA2/issues/95#issuecomment-1896400098

BaluPai commented 5 months ago

Hi,

I am getting the same error as above: G740S <- initiateSpataObject_10X( directory_10X = "10Xout_dir/outs/", # the directory from which to load the data sample_name = "G740" ) **Error in LayerData(): ! features must be a character vector, not a logical vector. Run rlang::last_trace() to see where the error occurred.

rlang::last_trace() <error/rlang_error> Error in LayerData(): ! features must be a character vector, not a logical vector.**

Backtrace: ▆

  1. └─SPATA2::initiateSpataObject_10X(...)
  2. └─SPATA2:::process_seurat_object(...)
  3. ├─base::rownames(...)
  4. ├─...[]
  5. └─SeuratObject:::[.Assay(...)
  6. ├─SeuratObject::LayerData(...)
  7. └─SeuratObject:::LayerData.Assay(features = i) Run rlang::last_trace(drop = FALSE) to see 4 hidden frames. rlang::last_trace(drop = FALSE) <error/rlang_error> Error in LayerData(): ! features must be a character vector, not a logical vector.

    Backtrace: ▆

  8. └─SPATA2::initiateSpataObject_10X(...)
  9. └─SPATA2:::process_seurat_object(...)
  10. ├─base::rownames(...)
  11. ├─...[]
  12. └─SeuratObject:::[.Assay(...)
  13. ├─SeuratObject::LayerData(...)
  14. └─SeuratObject:::LayerData.Assay(features = i)
  15. └─rlang::arg_match(...)
  16. └─rlang:::check_character(arg, arg = error_arg, call = error_call)
  17. └─rlang:::stop_input_type(...)
  18. └─rlang::abort(message, ..., call = call, arg = arg)

Appreciate your help or suggestions.

(In parallel, I am using Seurat to analyze the data. I am able to use- "SPATA2::asSPATA2" to create a spata2 object from the Seurat object.)

Thanks!

simonmfr commented 5 months ago

Hi, please update both SPATA2 and Seurat and check if it works now.

BaluPai commented 5 months ago

Hi @simonmfr ,

I wanted to keep the Seurat 4.3 on my R/4.2.2 for some continued analysis, so I installed R/4.3.2 and installed Seurat 5.0.1. But I am not able to install SPATA2 using the devtools command. Please see below:

devtools::install_github(repo = "theMILOlab/SPATA2") Downloading GitHub repo theMILOlab/SPATA2@HEAD ── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────── ✔ checking for file 'C:\Users\balag\AppData\Local\Temp\RtmpYdRuTE\remotes3b48166d13cd\theMILOlab-SPATA2-d32960b/DESCRIPTION' (370ms) ─ preparing 'SPATA2': (8.5s) ✔ checking DESCRIPTION meta-information ... ─ checking for LF line-endings in source and make files and shell scripts (3.4s) ─ checking for empty or unneeded directories ─ building 'SPATA2_2.0.4.tar.gz'

BaluPai commented 5 months ago

Follow up...

I proceeded anyway with updating Seurat 4.3 to 5.0.1 on R/4.2.2 and SPATA2 2.0.4.

'initiateSpataObject_10x' ran a bit further (See below) but did not generate an object from 10x visium folder.

G740S <-

  • initiateSpataObject_10X(
  • directory_10X = "C:/Users/...../10X_Visium/outs/", # the directory from which to load the data
  • sample_name = "G740"
  • ) 13:43:47 Starting initiation. 13:43:47 No gene-set data.frame path specified. 13:43:47 Reading in .h5 file. 13:43:47 Loading from directory: 'C:/Users/10XVisium/outs/' 13:43:54 Performing Seurat-analysis steps. 13:43:54 Calculating percentage of ribosomal and mitochondrial genes. 13:43:55 Removing stress genes and mitochondrial genes. 13:43:56 Skip running 'SCTransform()' as it's argument input is neither TRUE nor a list. 13:43:56 Running 'Seurat::NormalizeData()' with specified parameters. Normalizing layer: counts Performing log-normalization 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 13:43:59 Running 'Seurat::FindVariableFeatures()' with specified parameters. Finding variable features for layer counts Calculating gene variances 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| Calculating feature variances of standardized and clipped values 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 13:44:01 Running 'Seurat::ScaleData()' with default parameters. Centering and scaling data matrix |==================================================================================================| 100% 13:44:07 Running 'Seurat::RunPCA()' with specified parameters. PC 1 Positive: SNAP25, NRGN, IDS, RTN1, SYT1, VSNL1, SYN1, ATRNL1, SLC1A2, SNCA CHN1, NAPB, TMEM130, SYN2, PHYHIP, SNCB, CAMK2A, YWHAH, CA11, NCDN GRIN1, TMEM59L, CPLX2, NEFL, GNG3, DNM1, SYP, ENC1, DMTN, PACSIN1 Negative: MDM2, TSFM, CDK4, MARCH9, SLC35E3, METTL1, PTPRZ1, TUBB2B, SPP1, SOX4 SOX2, VCAN, BCAN, MARCKS, EEF1AKMT3, DPYSL3, GNB4, TOP2A, HIST1H1B, PMP2 ACTB, ID3, NES, CDKN2A, SERPINA3, ETV1, VIM, DCX, TUBA1A, PLPPR1 PC 2 Positive: GAP43, AKAP12, VGF, SERPINE1, CA9, ADM, VEGFA, CAV1, ENO2, COL5A1 FAM162A, TMEM158, ARL4C, NRN1, HILPDA, TNC, PLOD2, ERO1A, SLC2A1, IGFBP3 IGFBP2, JUN, RDH10, SPOCD1, LOX, GPRC5A, COL6A1, HK2, BHLHE40, STAC2 Negative: PLP1, GFAP, C3, IFIT3, MOBP, ISG15, CD74, AQP1, IFI44L, APOD MX1, CLDN11, IFIT2, PLAAT4, OAS2, OAS1, VSIG4, TRIM22, OAS3, TYMP PARP14, IFI44, RSAD2, HSPA2, RNASE1, SPARC, APOL6, UGT8, IFI35, CMPK2 PC 3 Positive: PFN2, CSPG5, NNAT, ENC1, TMEM132B, SCN3A, COL20A1, NRXN2, TNS3, PRICKLE1 RGMB, DNM1, VSNL1, GABRG2, CADM3, NSF, CRMP1, SHD, PHYHIP, DLL3 TOP2A, NCDN, MDFI, TMEM59L, CLSTN3, BSN, NPTXR, SCN3B, SYP, SLC8A3 Negative: NDRG1, GFAP, SPARC, CRYAB, RNASE1, PLP1, MOBP, PMP22, SERPINE1, ADM SLC2A1, MYLK, HSPA2, FTL, CD9, VIM, EGLN3, IGFBP3, CA9, CD44 DDIT3, TNC, CAV1, ANGPTL4, ANXA5, TAGLN, FLNC, ITGA5, ANXA1, TNFRSF12A PC 4 Positive: GFAP, C1orf61, DLX5, TNIK, PLP1, HIST1H1B, EGFR, PCBP4, LFNG, HIST1H1C CRABP1, MDFI, TSPAN18, SOX4, FADS2, INSM1, NOTCH1, NR4A1, NFIA, ERBB3 HSPA2, NT5DC2, UGT8, HIST1H1D, COL9A3, SOX10, RGMA, NTRK2, HES5, ROBO3 Negative: CXCL10, CXCL11, GBP1, RSAD2, IFIT2, IFIT3, CCL8, OASL, CALHM6, IFIH1 MX1, IRF1, WARS, IDO1, ISG20, TNFSF10, CCL2, HAMP, MX2, CMPK2 PARP14, APOL6, IL4I1, SAMD9, IFI35, DDX60L, DDX58, OAS1, OAS3, VCAM1 PC 5 Positive: NTRK2, LAMP5, NECAB2, PCDH8, CALB2, GNAL, PLTP, IL1R2, MASP1, CBLN4 AKAP5, TXNIP, CA3, ACVR1C, NDUFA4L2, LRATD1, DDR1, SOWAHA, IFI27, JAM2 EZR, WIF1, H1F0, CHST9, HMOX1, CRABP1, RGMA, SPARC, TESPA1, OBSL1 Negative: VGF, SERPINE1, CLSTN2, SPOCD1, HS3ST2, TNFRSF12A, BMPER, TNS3, GPRC5A, EMP1 CHI3L2, UPP1, UBD, SEMA5A, IGFBP3, KRT75, AVIL, GPR17, TP73, TMEM158 CPNE4, CDK4, CHGA, MARCH9, RDH10, FOSL1, NPY, ITGA5, LIMA1, CPA4 13:44:18 Running 'Seurat::FindNeighbors()' with specified parameters. Computing nearest neighbor graph Computing SNN 13:44:19 Running 'Seurat::FindClusters()' with specified parameters. Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck

Number of nodes: 4322 Number of edges: 177023

Running Louvain algorithm... 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| Maximum modularity in 10 random starts: 0.8501 Number of communities: 12 Elapsed time: 0 seconds 13:44:20 Running 'Seurat::RunTSNE()' with default parameters. 13:44:30 Running 'Seurat::RunUMAP()' with specified parameters. Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation' This message will be shown once per session 13:44:30 UMAP embedding parameters a = 0.9922 b = 1.112 Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics' Also defined by ‘spam’ 13:44:30 Read 4322 rows and found 30 numeric columns 13:44:30 Using Annoy for neighbor search, n_neighbors = 30 Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics' Also defined by ‘spam’ 13:44:30 Building Annoy index with metric = cosine, n_trees = 50 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 13:44:30 Writing NN index file to temp file C:\Users\balag\AppData\Local\Temp\RtmpioY0zI\file28643827351 13:44:30 Searching Annoy index using 1 thread, search_k = 3000 13:44:31 Annoy recall = 100% 13:44:32 Commencing smooth kNN distance calibration using 1 thread with target n_neighbors = 30 13:44:33 Initializing from normalized Laplacian + noise (using RSpectra) 13:44:33 Commencing optimization for 500 epochs, with 191104 positive edges Using method 'umap' 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **| 13:44:43 Optimization finished 13:44:43 Initiating spata2 object. 13:44:43 Setting up new spata2 object. 13:44:44 Transferring data. Error in value[3L] : Could not find count matrix in specified seurat object. Did you choose the correct method? In addition: Warning messages: 1: Layer ‘TRUE’ is empty 2: invoke() is deprecated as of rlang 0.4.0. Please use exec() or inject() instead. This warning is displayed once every 8 hours.

Please let me know if you have any suggestions! Like I mentioned earlier, I am able to convert object from Seurat and proceed with the analysis. I am not sure generating a SPATA2 object via Seurat or directly using "initiateSapataObject" will affect analysis or additional possibilities using SPATA2 tool.

Thanks.

simonmfr commented 4 months ago

Hi, unfortunately I cannot replicate your error using the latest SPATA2 and Seurat 5.0.1.

Alternatively you can of course transfer from Seurat, but in principle initiateSapataObject should work.

If you provide a reproducible example or share exemplary spaceranger output, I can have a detailed look.

Best, Simon

BaluPai commented 4 months ago

Hi Simon,

Thanks for looking into it. I can share with you the 10X/outs folder perhaps. Please let me know a convenient way to share it.

I have been doing SPATA2 analysis after converting Seurat to SPATA2. But as I assume some of the features/functions of the analysis gets affected ?! For e.g., I am not able to plot after DEA analysis, instead getting this error:

_" plotSurfaceComparison( object = G740S, color_by = top_5_markers_G740S , nrow = 3 ) legendNone() Error in check_variables(variables = color_by, all_gene_sets = all_gene_sets, : Could not find any of the specified input of 'variables' among genes, gene-sets and features.. In addition: Warning message: In check_variables(variables = color_by, all_gene_sets = all_genesets, : Unknown or invalid input: 'KRT5', 'SMCO2', 'LPAR4', 'MBP', 'LRRC57', 'SYN2',........!"

Best, Balu

kunstner commented 4 months ago

Hi Simon, I get exactly the same error using initiateSpataObject_10X (Seurat v5.0.1, SPATA2 v2.04) using 10x data mapped with spaceranger (v2.1.2). I did some initial analysis in autumn last year with some older software versions and everything was running smoothly using the same data. Best, Axel

simonmfr commented 4 months ago

@BaluPai, if you could share a download link to your file via email, I can try to reproduce the error - thank you

simonmfr commented 4 months ago

Hi, thanks for sharing the data. Unfortunately I cannot replicate the error, therefore it's difficult to troubleshoot.

spata_object <- SPATA2::initiateSpataObject_10X(directory_10X = path,
                                                sample_name = "test"
                                               )
SPATA2::plotSurfaceComparison(
    object = spata_object,
    color_by = SPATA2::getGenes(spata_object)[1:3],
)
image

..runs without errors.

I guess your issue has to do with the versioning, did you try to re-install SPATA2? We did a minor bug fix recently without making a release.

kunstner commented 4 months ago

Hi @simonmfr,

it seems I did not updated to the latest version. I just re-installed SPATA2 and it's working.

Best, Axel