SPARK
SPARK copied to clipboard
Infinite error and possible memory leakage when using "poisson" fit.model
Occurred while using FFPE_DCIS data from 10x genomics
The code block below will produce the following message until the end of wall time or until exceeding RAM:
Error in spark.ai(model0, num_vc, fixtau = fixtau.old, maxiter = maxiter, : object 'Py' not found In addition: Warning messages: 1: In asMethod(object) : sparse->dense coercion: allocating vector of size 1.4 GiB 2: In asMethod(object) : sparse->dense coercion: allocating vector of size 1.4 GiB 3: glm.fit: algorithm did not converge 4: glm.fit: fitted rates numerically 0 occurred 5: glm.fit: fitted rates numerically 0 occurred Error in spark.ai(model0, num_vc, fixtau = fixtau.old, maxiter = maxiter, : object 'Py' not found In addition: Warning messages: 1: In asMethod(object) : sparse->dense coercion: allocating vector of size 1.4 GiB 2: In asMethod(object) : sparse->dense coercion: allocating vector of size 1.4 GiB 3: glm.fit: algorithm did not converge 4: glm.fit: fitted rates numerically 0 occurred 5: glm.fit: fitted rates numerically 0 occurred
library(SPARK)
library(Seurat)
library(readr)
# read in count data
count = Read10X_h5('HBC_FFPE_DCIS/Visium_FFPE_Human_Breast_Cancer_raw_feature_bc_matrix.h5')
dim(count) # 36945 4992
# read in and format location information
loc = read.csv("HBC_FFPE_DCIS/tissue_positions_list.csv", header = F)
rownames(loc) = loc[,1] # set cell IDs to row names
loc = loc[, c('V5','V6')]
colnames(loc) = c('x','y')
loc= loc[match(colnames(count),rownames(loc)), ] # want matching cell IDs
loc = as.data.frame(loc) # set as dataframe
rownames(loc) = colnames(count) # set cell IDs matching in count matrix col names to row names
num_cores = 18 # using 18 out of 36 cores
# filter out mitochondrial genes
mt_idx = grep("MT-",rownames(count))
if(length(mt_idx)!=0){
count = count[-mt_idx,]
}
# fit and test SPARK model
spark_p = CreateSPARKObject(counts=count, location=loc, percentage = 0, min_total_counts = 0)
spark_p@lib_size = apply(count, 2, sum)
spark_p = spark.vc(spark_p,
covariates = NULL,
lib_size = spark_p@lib_size,
num_core = num_cores,
verbose = F,
fit.model = "poisson")
spark_p = spark.test(spark_p,
check_positive = T,
verbose = F)