Hello all, I am doing gene expression profiling of 3 structures(BB, 79A, 28z). I have 9 samples from 3 donors. Each donor has 3 samples, representing 3 structures. For example Donor 1 has structure BB, 79A, 28z , Donor 2 has structure BB, 79A, 28z Donor 3 has structure BB, 79A, 28z. I would like to see the differentially expressed gene of structure 79A. I compare structure 79A vs 28z, 79A vs BB and 28z vs BB. I have tried both classic and glm approach. I got 24 DEGs in classic but only 6 DEGs in GLMs approach. Thank you in advance!!
The following are my script in classic approach (comparing 79A vs 28z)
counts <- read.table('NewCounting_file.txt')
head(counts)
str(counts)
#create gene name and gene id variable
gene_name <- counts[,2]
gene_id <- counts[,1]
class(counts)
head(gene_id)
head(gene_name)
#Delete gene id and gene name column on counts
counts[1:2] <- list(NULL)
head(counts)
##Delete BB group V3 &V6
counts[1] <- list(NULL)
counts[3] <- list(NULL)
head(counts)
#create gene count numeric matrix
counts_mat <- apply(as.matrix.noquote(counts),2,as.numeric)
head(counts_mat)
class(counts_mat)
row.names(counts_mat) <- gene_name
head(counts_mat)
newsample_name <- c("79A","28z","79A","28z","79A","28z")
colnames(counts_mat) <- newsample_name
head(counts_mat)
library(edgeR)
#create group variables
groups79A_28z <- c("79A","28z","79A","28z","79A","28z")
geneexp79A_28z <- DGEList(counts=counts_mat, group=groups79A_28z)
head(geneexp79A_28z)
geneexp79A_28z <- calcNormFactors(geneexp79A_28z)
head(geneexp79A_28z)
geneexp79A_28z<- estimateCommonDisp(geneexp79A_28z)
head(geneexp79A_28z)
geneexp79A_28z <- estimateTagwiseDisp(geneexp79A_28z)
head(geneexp79A_28z)
filterByExpr(geneexp79A_28z)
head(geneexp79A_28z)
genediff79A_28z <- exactTest(geneexp79A_28z)
genediff79A_28z
topTags(genediff79A_28z)
str(genediff79A_28z)
genediff79A_28z$table <- cbind(genediff79A_28z$table, FDR=p.adjust(genediff79A_28z$table$PValue, method ='fdr'))
head(genediff79A_28z)
str(genediff79A_28z)
gsign79A_28z <- genediff79A_28z$table[genediff79A_28z$table$FDR<0.05,]
gsign79A_28z <- gsign79A_28z[order(gsign79A_28z$FDR),]
dim(gsign79A_28z)
head(gsign79A_28z)
---------
Below is my glm approach
counts <- read.table('NewCounting_file.txt')
head(counts)
str(counts)
#create gene name and gene id variable
gene_name <- counts[,2]
gene_id <- counts[,1]
class(counts)
head(gene_id)
head(gene_name)
#Delete gene id and gene name column on counts
counts[1:2] <- list(NULL)
head(counts)
##Delete BB group V3 &V6
counts[1] <- list(NULL)
counts[3] <- list(NULL)
head(counts)
#create gene count numeric matrix
counts_mat <- apply(as.matrix.noquote(counts),2,as.numeric)
head(counts_mat)
class(counts_mat)
row.names(counts_mat) <- gene_name
head(counts_mat)
newsample_name <- c("79A","28z","79A","28z","79A","28z")
colnames(counts_mat) <- newsample_name
head(counts_mat)
library(edgeR)
#create group variables
group <- c("79A","28z","79A","28z","79A","28z")
dglist <- DGEList(counts=counts_mat, group=group)
keep <-filterByExpr(dglist)
summary(keep)
dglist <- dglist[keep, ,keep.lib.sizes=FALSE]
dim(dglist)
dglist <- calcNormFactors(dglist, method="TMM")
plotMDS(dglist)
dglist$samples
#Design matrix
group <- factor(dglist$samples, levels=c("79A","28z"))
design <- model.matrix(~0 +group)
design
dglist<- estimateDisp(dglist)
dglist$common.dispersion
plotBCV(dglist)
fit <- glmQLFit(dglist)
head(fit$coefficients)
plotQLDisp(fit)
Could you please help me explain the coef value? how to calculate its value ? Currently I got only 8 samples as another 1 is still in the process of sequencing but I want to try analyze these 8 samples first. Does the order of treatment ( A, B, C, B,A,C , C,B,A) correlate with coef value? Thank you so much for your comment, It means a lots to me, I try so hard to understand and writing the new script.
Excuse me Gordon Smyth, Could you help me review my new script following your guidance last 2 days please, I have tried to write again. I have attached the pheno column in the picture. Currently I have only 8 samples to analyze. Thank you in advance!
enter image description here