plotMD plot change plot title
1
0
Entering edit mode
mictadlo ▴ 10
@mictadlo-10885
Last seen 4.3 years ago

Hi, The plotMD get as title the whole file path. How would it be possible to have e.g. only the file name rather than the whole path as plot title?

library(edgeR)
# where are we?
basedir <- "~/projects/mel/Sp/"
setwd(basedir)

tayets <- read.delim("phenoSp.txt", stringsAsFactors=FALSE)
tayets

## ----group---------------------------------------------------------------
group <- paste(tayets$CellType, tayets$Status, sep=".")
group <- factor(group)
table(group)


cntdir <- paste(basedir, "Htseq_read_counts", sep="/")
pat <- "sorted.out"
files <- list.files(path = cntdir,
                    pattern = pat,
                    all.files = TRUE,
                    recursive = FALSE,
                    ignore.case = FALSE,
                    full.names = TRUE,
                    include.dirs = FALSE)

files
y <- readDGE(files, header=FALSE, group = group)
y

# Filtering to remove low counts
keep <- rowSums(cpm(y)>1) >= 2
table(keep)

y <- y[keep, , keep.lib.sizes=FALSE]

# Normalization for composition bias
y <- calcNormFactors(y)
y$samples

#Exploring differences between libraries
## ----mdsplot, fig.cap="The MDS plot of the data set. Samples are separated by the cell type in the first dimension, and by the mouse status in the second dimension."----
pch <- c(0,1,2,15,16,17)
colors <- rep(c("darkgreen", "red", "blue"), 2)
plotMDS(y, col=colors[group], pch=pch[group])
legend("topleft", legend=levels(group), pch=pch, col=colors, ncol=2)

## ----mdplot1, fig.cap="MD plot of log2-expression in sample 1 versus the average log2-expression across all other samples. Each point represents a gene, and the red line indicates a log-ratio of zero. The majority of points cluster around the red line."----
plotMD(y, column=1)
abline(h=0, col="red", lty=2, lwd=2)

Thank you in advance.

edger plotmd • 2.3k views
ADD COMMENT
2
Entering edit mode
@gordon-smyth
Last seen 3 hours ago
WEHI, Melbourne, Australia

By default, the column names of y are just the entries from your files vector. To control the plot title, you either reset the column names of y by

colnames(y) <- whatever you want

or use the main argument of plotMD() to set your own title:

plotMD(y, column=1, main="MD plot of my first sample")
ADD COMMENT
0
Entering edit mode

It worked with `colnames(y) <- gsub("\\.sorted", "", basename(colnames(y)))`.

ADD REPLY

Login before adding your answer.

Traffic: 517 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6