rdimensionality-reductionseuratrna-seqrunumap

scRNAseq UMAP error with FindVariableFeatures


I am new to scRNAseq analysis and am self-taught so apologies if this is really basic!

I have downloaded metadata and TPM counts for a scRNAseq dataset (https://github.com/Martin-Villalba-lab/Data/tree/master/Cell_2019/SmartSeq2).

My goal is to generate UMAP plots and colour by several genes I am interested in. This is the code I am using:

    NSCs_annotation <- read.csv(file = "count_table/cell_annotation_NSC_Astro/cell_annotation.csv" , row.names = 1)
    TPM_NSCs <- read.csv(file = "count_table/TPM_NSC_and_Astro/old_young_combined/Gene_expression_matrix_TPM_all.csv" , row.names = 1)
    rownames(NSCs_annotation) <- NSCs_annotation$cell
    head( NSCs_annotation )
    TPM_NSC <- remove_rownames(TPM_NSCs) %>% column_to_rownames( var = "gene_id")
    seurat_sms2 <- CreateSeuratObject(counts = TPM_NSC  , 
                                  project = "young_vs_old_SmartSeq2",
                                  min.cells = 3 ,
                                  min.features = 200)

This is where I keep getting an error:

    obj <- seurat_sms2
    obj <- NormalizeData(obj)
    obj <- FindVariableFeatures(obj) #Error: 'VST.default' is not implemented yet
    obj <- ScaleData(obj)
    obj <- RunPCA(obj)

I am using RStudio Version 2023.06.0+421 (2023.06.0+421) on mac, and Seurat version 4.9.9.9049

Does anyone have any advice? Thanks in advance!

EDIT - the error was because I was using a data.frame for the counts data when making the SeuratObject, this was resolved with the following code to convert the count data to a matrix:

counts_matrix = Matrix(as.matrix(TPM_NSC) , sparse=TRUE)

Solution

  • Just the simple line conversion of the dataframe to a sparse matrix actually saved me from days of trying to debug both this error and another one I run into when using the FindNeighbours function:

    Error in validityMethod(as(object, superClass)) : object 'CsparseMatrix_validate'