Entering edit mode
20 months ago
kalyani
▴
10
I am working DESeq2 I wanted I proper boxplot but I don't understand what wrong I am doing and I wanted to know how to properly plot the x and y axis what parameters should be taken for boxplot . here's my code:
library("DESeq2")
library("ggplot2")
counts<-read.delim("PC_1.csv",header = TRUE, row.names = 1, sep = ",")
counts
#condition c=control P=patient
condition <- factor(c("C","C","C","C","C","C","C","C","P","P","P","P","P","P","P","P"))
condition
#creating data frame of condition and samples
coldata <- data.frame(row.names = colnames(counts), condition)
coldata
#?DESeqDataSetFromMatrix
dds <- DESeqDataSetFromMatrix(countData = counts, colData = coldata, design = ~condition)
dds <- DESeq(dds)
#vst-variance stabilizing transformation
vsdata <- vst(dds, blind = FALSE)
#QC of data
plotPCA(vsdata, intgroup="condition")
#dispersion of data- ability between replicates as a function of normalized read counts(red line below 1)
plotDispEsts(dds)
#table of DEG compared p vs c
res <- results(dds, contrast = c("condition","P","C"))
res
#log2FC= +ve- upregulated ,-ve downregulated samples
#padj=p adjusted value
#new table for filtering gene which has padj value less than 0.05
sigs <- na.omit(res)
sigs <- sigs[sigs$padj < 0.05,]
sigs
library(ComplexHeatmap)
library(org.Hs.eg.db)
sigs.df <- as.data.frame(sigs)
#filtering
sigs.df <- sigs.df[(sigs.df$baseMean>100) & (abs(sigs.df$log2FoldChange)>1),]
sigs.df
#normalized counts
mat <- counts(dds, normalized = TRUE)[rownames(sigs.df),]
#z-score for each row
t(apply(mat, 1, scale))
colnames(mat) <- rownames(coldata)
mat
heatmap(mat,cluster_rows = T, cluster_columns = T, column_lables=colnames(mat), name="z-score")
boxplot(mat,
xlab="",
ylab="",
las=2,
col="red")
Please get used to make your question reproducible and precise, meaning provide example data and reduce code to a minimum.