welch-lab / liger

R package for integrating and analyzing multiple single-cell datasets
GNU General Public License v3.0
389 stars 78 forks source link

scaleNotCenter Error #214

Closed Ping-lin14 closed 3 years ago

Ping-lin14 commented 3 years ago

Hi

I receive an error when I try to merge ATAC data with RNA data int.bmmc <- scaleNotCenter(int.bmmc) Error in asMethod(object) : Cholmod error 'problem too large' at file ../Core/cholmod_dense.c, line 102

I want to know what could be causing this? How to solve it?

I use windows 10 platform. code:

library(rliger)
setwd("C:/Users/ping/Desktop/ATAC/liger_test/ATAC")
genes.bc <- read.table(file = "atac_genes_bc.bed", sep = "\t", as.is = c(4,7), header = FALSE)
promoters.bc <- read.table(file = "atac_promoters_bc.bed", sep = "\t", as.is = c(4,7), header = FALSE)

bc <- genes.bc[,7]
bc_split <- strsplit(bc, ";")
bc_split_vec <- unlist(bc_split)
bc_unique <- unique(bc_split_vec)
bc_counts <- table(bc_split_vec)
bc_filt <- names(bc_counts)[bc_counts > 1500]
barcodes <- bc_filt

gene.counts <- makeFeatureMatrix(genes.bc, barcodes)
promoter.counts <- makeFeatureMatrix(promoters.bc, barcodes)

gene.counts <- gene.counts[order(rownames(gene.counts)),]
promoter.counts <- promoter.counts[order(rownames(promoter.counts)),]
D5T1 <- gene.counts + promoter.counts
colnames(D5T1)=paste0("D5T1_",colnames(D5T1))

bmmc.rna <- read10X(sample.dirs = list("C:/Users/ping/Desktop/ATAC/liger_test/RNA/raw_feature_bc_matrix"), sample.names = "rna")

bmmc.data <- list(atac = D5T1, rna = bmmc.rna)
int.bmmc <- createLiger(bmmc.data)
rm(genes.bc, promoters.bc, gene.counts, promoter.counts, D5T1, bmmc.rna, bmmc.data)
gc()

int.bmmc <- normalize(int.bmmc)
int.bmmc <- selectGenes(int.bmmc, datasets.use = 1)
int.bmmc <- scaleNotCenter(int.bmmc)
cgao90 commented 3 years ago

Hi @Ping-lin14

The issue is associated with as.matrix() trying to convert a really large sparse matrix (raw_feature_bc_matrix in your case) into a dense one. filtered_feature_bc_matrix should be the input to the read10X function (raw vs filtered gene-barcode matrix: https://kb.10xgenomics.com/hc/en-us/articles/360001892491-What-is-the-difference-between-the-filtered-and-raw-gene-barcode-matrix-).

If you are only trying to go through the tutorial, please download the RNA data from here (https://umich.app.box.com/s/wip2nzpktn6fdnlpc83o1u7anjn4ue2c) and run the following code

rna1 <- readRDS('~/Downloads/GSM4138872_scRNA_BMMC_D1T1.rds')
rna2 <- readRDS('~/Downloads/GSM4138873_scRNA_BMMC_D1T2.rds')
bmmc.rna <- cbind(rna1,rna2)

Best, Chao

Ping-lin14 commented 3 years ago

Thank you very much for your answers.