Hello,
I'm trying to remove unwanted variables using RUVSeq and SVA but i'm meeting an issue with both libraries.
with RUVSeq I get this "list" error:
> for(k in 1:4) {
+ set_g <- RUVg(x = gg, cIdx = house_keeping_genes, k = k)
+ DESeq2::plotPCA(set_g, col=as.numeric(coldata$group))
+ }
Error in Ycenter[, cIdx] : invalid subscript type 'list'
while with SVA I get this:
> res <- svaseq(norm_by_count_per_million, mod, mod0)
Number of significant surrogate variables is: 46
Iteration (out of 5 ):Error in density.default(x, adjust = adj) : 'x' contains missing values
I've found a couple of references but haven't been able to fix these issues.
Full reproducible example bellow, any help would be much appreciated!
library(SummarizedExperiment)
library(RUVSeq)
library(sva)
# http://duffel.rail.bio/recount/v2/TCGA/rse_gene_bladder.Rdata
load('data/rse_gene_bladder.Rdata')
unique(rse_gene$gdc_cases.diagnoses.tumor_stage)
colData(rse_gene)$group <- NA
rse_gene$gdc_cases.diagnoses.tumor_stage == "stage iv"
colData(rse_gene)$group[rse_gene$gdc_cases.diagnoses.tumor_stage == "stage i"] <- "early"
colData(rse_gene)$group[rse_gene$gdc_cases.diagnoses.tumor_stage == "stage ii"] <- "early"
colData(rse_gene)$group[rse_gene$gdc_cases.diagnoses.tumor_stage == "stage iii"] <- "late"
colData(rse_gene)$group[rse_gene$gdc_cases.diagnoses.tumor_stage == "stage iii"] <- "late"
keep <- !is.na(rse_gene$group)
rse_gene <- rse_gene[, keep]
table(rse_gene$group)
counts <- assay(rse_gene, "counts")
norm_by_count_per_million <- sweep(counts, 2, FUN="/", colSums(counts)) * 10^6
coldata <- colData(rse_gene)
HK_genes <- read.table(url("https://m.tau.ac.il/~elieis/HKG/HK_genes.txt"))
house_keeping_genes <- intersect(rowRanges(rse_gene)$symbol, HK_genes$V1)
gg <- ceiling(norm_by_count_per_million)
rownames(gg) <- as.vector(rowRanges(rse_gene)$symbol)
par(mfrow = c(2, 2))
for(k in 1:4) {
set_g <- RUVg(x = gg, cIdx = house_keeping_genes, k = k)
DESeq2::plotPCA(set_g, col=as.numeric(coldata$group) )
}
mod <- model.matrix(~group, data=coldata)
mod0 <- model.matrix(~1, data=coldata)
res <- svaseq(norm_by_count_per_million, mod, mod0)
rnaseq