Doubts with Stacked barplot using R ggplot2

Doubts with Stacked barplot using R ggplot2

0

Hello! I am trying to plot some data using R but I am having some problems doing it. I have a data frame with two columns (genes and and type of mutation) and looks like:

genes variant
MLH1 Intronic
ATR 5′ UTR
TP53 missense
KRAS Silent
POLE Intronic
MLH1 missense
BRAF Intronic
ATRX Silent

So I would like to graph the 25 most mutated genes in a stacked barplot, but the closest I get is this: enter image description here

I am using the ggplot2 library and my code is this:

ggplot(Genes_variantclassification, aes(x = genes, y = 1))+
geom_col(aes(fill = variant), width = 0.7)+
theme(axis.text.x = element_text(angle = 90,size=rel(0.2)))

I know this is probably a very basic question but I am really novice using R, so I would really appreciate your guide.


stacked


rstudio


ggplot2


barplot

• 17 views

Read more here: Source link

Tagged