# Error in my RNAseq analysis

I was following the RNAseq analysis tutorial online(https://combine-australia.github.io/RNAseq-R/06-rnaseq-day1.html) but am not obtaining the same variance values for each row in the logcounts matrix. Please could you help me identify the error.

library(edgeR)
library(limma)
library(Glimma)
library(org.Mm.eg.db)
library(RColorBrewer)
library(gplots)

seqdata <- read.delim("data/GSE60450_Lactation-GenewiseCounts.txt", stringsAsFactors = FALSE)
dim(seqdata)
sampleinfo

##Format the data
countdata <- seqdata[,-(1:2)]
rownames(countdata) <- seqdata[,1]
colnames(countdata)
colnames
colnames(countdata) <- substr(colnames(countdata),start=1,stop=7)
sampleinfo
table(colnames(countdata)==sampleinfo$SampleName) ##Filtering to remove lowly expressed genes #Obtain CPMs myCPM <- cpm(countdata) head(myCPM) thresh <- myCPM > 0.5 head(thresh) table(rowSums(thresh)) keep <- rowSums(thresh) >=2 #Subset the rows of countdata to keep the more highly expressed genes counts.keep <- countdata[keep,] summary(keep) dim(counts.keep) #Find out whether CPM threshold corresponds to a count of around 10-15 #Look at first sample plot(myCPM[,1],countdata[,1],ylim=c(0,50),xlim=c(0,3)) abline(v=0.5) #Convert counts to edgeList objects y <- DGEList(counts.keep) y names(y) y$samples

###Quality Control

#Check the number of reads we have for each sample in y
y$$samples$$lib.size
#Barplot of library size to spot any major discrepancies between the samples
barplot(y$$samples$$lib.size, names=colnames(y),las=2)
title("Barplot of Library Sizes")
#Get log2 CPM
logcounts <- cpm(y,log=TRUE)
#Check distribution of samples using boxplots
boxplot(logcounts, xlab="",ylab="log2 CPM", las=2, ylim=c(-10,15))
#Add a horizontal line corresponding to the median logCPM
abline(h=median(logcounts), col="blue")
title("Boxplots of logCPMs (unnormalised)")

##Heirarchical clustering with heatmaps
#Estimate the variance for each row in the logcounts matrix
var_genes <- apply(logcounts,1,var)