ddsMat_rlog<-rlog(ddsMat,blind=TRUE)mat<-assay(ddsMat_rlog[row.names(results_sig)])[1:18,]##annotation_col=data.frame(Group=factor(colData(ddsMat_rlog)$Group),row.names=colData(ddsMat_rlog)$sampleid)##ann_colors=list(Group=c("0day"="#E65100","1day"="#66BB6A","3day"="#03A9F4"),sampleid=c(a="red"))##pheatmap(mat=mat,color=viridis(180),scale="row",# Scale genes to Z-score (how many standard deviations)annotation_col=annotation_col,# Add multiple annotations to the samplesannotation_colors=ann_colors,# Change the default colors of the annotationsfontsize=7,# Make fonts smallercellwidth=30,# Make the cells widercutree_cols=3,cutree_rows=4,show_colnames=F)pheatmap(mat=mat,color=viridis(180),scale="row",# Scale genes to Z-score (how many standard deviations)annotation_col=annotation_col,# Add multiple annotations to the samplesannotation_colors=ann_colors,# Change the default colors of the annotationsfontsize=7,# Make fonts smallercellwidth=30,# Make the cells widercutree_cols=3,cutree_rows=4,cluster_cols=F,show_colnames=F)
# Gather Log-fold change and FDR-corrected pvalues from DESeq2 results## - Change pvalues to -log10 (1.3 = 0.05)data_vp<-data.frame(gene=row.names(results),pval=-log10(results$padj),lfc=results$log2FoldChange)# Remove any rows that have NA as an entrydata_vp<-na.omit(data_vp)# Color the points which are up or down## If fold-change > 0 and pvalue > 1.3 (Increased significant)## If fold-change < 0 and pvalue > 1.3 (Decreased significant)data_vp<-mutate(data_vp,color=case_when(data_vp$lfc>0&data_vp$pval>1.3~"Increased",data_vp$lfc<0&data_vp$pval>1.3~"Decreased",data_vp$pval<1.3~"nonsignificant"))# Make a basic ggplot2 object with x-y valuesvol<-ggplot(data_vp,aes(x=lfc,y=pval,color=color))# Add ggplot2 layersvol+ggtitle(label="Volcano Plot",subtitle="Colored by fold-change direction")+geom_point(size=2.5,alpha=0.8,na.rm=T)+scale_color_manual(name="Directionality",values=c(Increased="#B8DE29FF",Decreased="#482677FF",nonsignificant="darkgray"))+theme_bw(base_size=14)+# change overall themetheme(legend.position="right")+# change the legendxlab(expression(log[2]("LoGlu"/"HiGlu")))+# Change X-Axis labelylab(expression(-log[10]("adjusted p-value")))+# Change Y-Axis labelgeom_hline(yintercept=1.3,colour="darkgrey")+# Add p-adj value cutoff linescale_y_continuous(trans="log1p")# Scale yaxis due to large p-v
plotMA(results,ylim=c(-5,5))plotDispEsts(ddsMat)
# Convert all samples to rlogddsMat_rlog<-rlog(ddsMat,blind=FALSE)# Get gene with highest expressiontop_gene<-rownames(results)[which.min(results$log2FoldChange)]# Plot single geneplotCounts(dds=ddsMat,gene=top_gene,intgroup="Group",normalized=T,transform=T)