Entering edit mode
5.7 years ago
salamandra
▴
550
When running this:
clusters <- degPatterns(cluster_rlog, metadata = TableBJ, time = "condition", col=NULL)
I get this error:
Error in lower.to.upper.tri.inds(n) : 'n' must be >= 2
and also get a warning:
Large number of genes given. Please,make sure is not an error. NormallyOnly DE genes are useful for this function.
How to solve the error?
My data looks like this:
head(cluster_rlog)
BJ_1 BJ_2 BJ_3 d15_CD49f+_1 d15_CD49f+_2 d25_CD49f+_1 d25_CD49f+_2 d25_CD49f+_3
ENSG00000000003 8.416135 8.458166 8.366318 7.870605 7.977721 7.790931 7.857108 8.043796
ENSG00000000457 7.374256 7.478103 7.333263 7.574723 7.376089 7.797221 7.623953 7.572987
ENSG00000001084 8.051259 8.078769 8.149138 8.368629 8.486787 8.241352 8.401051 8.431956
d25_CD49f+CD34+_1 d25_CD49f+CD34+_2 d25_CD49f+CD34+_3
ENSG00000000003 8.005091 8.215726 8.231341
ENSG00000000457 7.805268 7.804865 7.776632
ENSG00000001084 8.335795 8.529618 8.769456
TableBJ
sampleName fileName time celltype condition
1 BJ_1 1A_ATCACG_counts d0 BJ d0_BJ
2 BJ_2 2A_CAGATC_counts d0 BJ d0_BJ
3 BJ_3 3A_ATCACG_counts d0 BJ d0_BJ
4 d15_CD49f+_1 2B_ACTTGA_counts d15 CD49fposCD34neg d15_CD49fposCD34neg
5 d15_CD49f+_2 3B_CGATGT_counts d15 CD49fposCD34neg d15_CD49fposCD34neg
6 d25_CD49f+_1 1C_TTAGGC_counts d25 CD49fposCD34neg d25_CD49fposCD34neg
7 d25_CD49f+_2 2C_GATCAG_counts d25 CD49fposCD34neg d25_CD49fposCD34neg
8 d25_CD49f+_3 3C_TTAGGC_counts d25 CD49fposCD34neg d25_CD49fposCD34neg
9 d25_CD49f+CD34+_1 1E_ACAGTG_counts d25 CD49fposCD34pos d25_CD49fposCD34pos
10 d25_CD49f+CD34+_2 2E_GGCTAC_counts d25 CD49fposCD34pos d25_CD49fposCD34pos
11 d25_CD49f+CD34+_3 3F_GCCAAT_counts d25 CD49fposCD34pos d25_CD49fposCD34pos
Complete code follows:
library("DESeq2")
sampleNames <- c("BJ_1", "BJ_2", "BJ_3", "d15_CD49f+_1", "d15_CD49f+_2", "d25_CD49f+_1", "d25_CD49f+_2", "d25_CD49f+_3", "d25_CD49f+CD34+_1", "d25_CD49f+CD34+_2", "d25_CD49f+CD34+_3")
sampleFiles <- c("1A_ATCACG_counts", "2A_CAGATC_counts", "3A_ATCACG_counts", "2B_ACTTGA_counts", "3B_CGATGT_counts", "1C_TTAGGC_counts", "2C_GATCAG_counts", "3C_TTAGGC_counts", "1E_ACAGTG_counts", "2E_GGCTAC_counts", "3F_GCCAAT_counts")
time <- factor(c(rep('d0',3), rep('d15',2),rep('d25',6)))
celltype <- factor(c(rep('BJ',3),rep('CD49fposCD34neg',5),rep('CD49fposCD34pos',3)))
condition <- factor(paste0(time,'_',celltype))
TableBJ <- data.frame(sampleName = sampleNames, fileName = sampleFiles, time = time, celltype = celltype, condition=condition)
ddsBJ <- DESeqDataSetFromHTSeqCount(sampleTable = TableBJ, design= ~ condition)
ddsHTSeqBJ <- ddsBJ[rowSums(counts(ddsBJ)) > 1, ]
rld <- rlog(ddsHTSeqBJ, blind=TRUE)
dds_lrt <- DESeq(ddsHTSeqBJ, test="LRT", reduced = ~ 1)
dds_res <- results(dds_lrt, alpha = 0.05)
ddsdatres <- as.data.frame(dds_res)
ddsdatres <- ddsdatre[!is.na(ddsdatre$padj),]
expgenes <- ddsdatres
res.sig <- ddsdatres[ddsdatres$padj < 0.05,] # select just genes < 0.05
res.sig <- res.sig[order(res.sig$padj),] # and then sort this table by p-value (smaller p-values on top):
rld_mat <- assay(rld)
cluster_rlog <-subset(rld_mat, row.names(rld_mat)%in%row.names(res.sig))
library('DEGreport')
rownames(TableBJ) <- TableBJ[,1]
clusters <- degPatterns(cluster_rlog, metadata = TableBJ, time = "condition", col=NULL)