1
$\begingroup$

I have raw read counts of miRNAs in two conditions like below

> head(long1)
             miRNA Read count Condition
1:  hsa-miR-539-3p         33    living
2: hsa-miR-199b-5p        102    living
3: hsa-miR-146a-3p         27    living
4:   hsa-let-7a-3p        186    living
5:    hsa-miR-1275         54    living
6:  hsa-miR-29a-3p       6464    living
> 

For each individual miRNAs, I want to show the difference of raw read counts across conditions by

p=ggplot(data = long1, aes(x=long1$miRNA, y=long1$`Read count`)) + geom_boxplot(aes(fill=Condition))
p <- p + guides(fill=guide_legend(title="Condition"))
p <- p + xlab("miRNAs") + ylab("Raw mapped reads") + ggtitle("s vs living with cancer")
p + facet_wrap( ~ miRNA, scales="free")+theme_bw() add_pval(p, pairs = list(c("s", "living")), test='wilcox.test')

Which returns this

[![enter image description here][1]][1]

This plot is not good

How I can a plot like below in which miRNAs are on Y axis and two colours shows the conditions like this

enter image description here

$\endgroup$

1 Answer 1

4
$\begingroup$

Using Google well is one of the best skillsets you can possibly learn in programming-allied fields. The style of plot you're looking for is a "grouped bar plot". I googled "r grouped bar plot" and found a nice link: https://www.r-graph-gallery.com/48-grouped-barplot-with-ggplot2.html

The key is to use position=dodge alongside color=Condition, x="Read count", y=miRNA )not sure ow you'd quote the name "Read count", might be better off renaming that column to readcount).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.