How to mark/ highlights specific points (expression value) in boxplot in R
1
1
Entering edit mode
6.4 years ago
Mike ★ 1.9k

Hi All,

Sorry for technical question.

I am trying to make a boxplot of gene expression data for some samples, and wanted to highlight specific points (expression value) based on gene name "TP53". I am able to highlight color in scatter plot but couldn't in boxplot, my code for scatter plot is

 plot(datamtx, col=ifelse(rownames(datamtx)=="TP53","red","black"))

I tried similar function for Boxplot but doesn't work..

boxplot(datamtx, labels=ifelse(rownames(datamtx)=="TP53","red","black"))

and

boxplot(datamtx, col=ifelse(rownames(datamtx)=="TP53","red","black"))

please help.

Thanks

R Boxplot • 8.5k views
ADD COMMENT
6
Entering edit mode
6.4 years ago
# Simulate a two column (tumor and normal) data with 10 genes. Gene names as row names
df=data.frame(normal=rnorm(10,60,5), tumor=rnorm(10,70,4))
row.names(df)=paste0("gene_",seq(1:10))
# Draw box plot
boxplot(df)
# Highlight the gene "gene_4" on box plot. Gene names are represented by row names
stripchart(df["gene_4",], vertical = T, method = "jitter", add=T, pch=20, col=as.factor(colnames(df)))

Rplot01

ADD COMMENT
0
Entering edit mode

Thanks a lot, @cpad0112

ADD REPLY

Login before adding your answer.

Traffic: 1474 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