#下面的方法不能安装
source("https://bioconductor.org/biocLite.R")
biocLite("cqn")
#Install MDSeq from local source with
#install.packages("MDSeq_1.0.5.tar.gz", repos=NULL, type="source")
#Install MDSeq from GitHub with
library(devtools)
install_github("zjdaye/MDSeq")
data(sampleData)
# raw count table
dat <- sample.exprs
dim(dat)
dat[1:6, 1:6]
# covariates
X <- sample.pheno[,c("X1","X2")]
head(X)
# group information
group <- sample.pheno$group
#键入summary(lmfit)将显示分析结果的统计概要,
summary(factor(group))
# lowly expressed genes were filtered by mean cpm value across all samples
dat.filtered <- filter.counts(dat, mean.cpm.cutoff = 0.1)
dim(dat.filtered)
# Using normalized counts
dat.normalized <- normalize.counts(dat.filtered, group=group, method="TMM")
# including normalization factor as an offset in the mean-dispersion GLMs
cnf <- calcNormFactors(dat.filtered, method="TMM")
libsize <- colSums(dat.filtered) #normalization factor
rellibsize <- libsize/exp(mean(log(libsize))) #relative library size
nf <- cnf * rellibsize #normalization factor including library size
get.model.matrix(factor(rep(1:3,each=4)))
get.model.matrix(factor(rep(1:3,each=4)), contrast.type = "contr.treatment")
# treatment group assignment
group <- factor(sample.pheno$group, labels = c("Control", "Case"))
table(group)
# make design matrix with proper contrast setting
groups <- get.model.matrix(group)
groups
# Check outliers using parallel process with 4 threads
# For the sake of simplicity, we demonstrate outlier detection
# by using the first 1,000 genes.
dat.checked <- remove.outlier(dat.normalized[1:1000, ], X=X, U=X, contrast = groups, mc.cores = 4)
head(dat.checked$outliers)
# status of outlier checking
table(dat.checked$outliers$status)
# frequency distribtuion of outliers
table(dat.checked$outliers$num.outliers)
# remove genes with status flag other than 0
counts <- dat.checked$count[dat.checked$outliers$status==0,]
dim(counts)
# using parallel process with 4 threads
fit <- MDSeq(counts, X=X, U=X, contrast = groups, mc.cores = 4)
# simultaneously test zero-inflation
head(fit$Dat[c("s","ZI.pval", "ZI")], 20)
# given log2-fold-change threshold = 1
result <- extract.ZIMD(fit, compare = list(A="Case", B="Control"), log2FC.threshold = 1)
head(result)
sessionInfo()
MDSeq-R包的学习笔记(直接粘贴代码)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...