I am shifting from excel to R for creating better plots and am working on creating stacked bar plot in R showing the three columns Percent.Exonic, Percent.Intronic and Percent.Intergenic in one stack for each of the samples. The values of these stack plot add upto 100. There are multiple columns after these three columns in my dataset.
I have large dataset which looks like this ( I read it from a text file to a table) -
Sample_ID Gene_ID Percent.Mapped.Reads Percent.Exonic Percent.Intronic Percent.Intergenic Col7 Col8 Col9 Col10
AAl 79.46 ABC 85 10 5 . . .
AA2 83.39 X82 96 2 2 . . .
AAL3 AB9292 91.89 90 5 5 . . .
AAL5 uw20 89.34 90 0 10
PBS1 wiw0 82.4 88 2 12
PBS3 vh27 81.88 100 0 0
Imr90_Rep2_54 eg282 92.29 100 0 0
Imr90_Rep2_72 yrt363 90.62 100 0 0
[![enter image description here][1]][1]can someone please share on how to get this plot with all samples in it?
I have this code so far, but I am getting confused as few previous posts on this topic use as.matrix as well? -
alignment <- read.table("Alignment.txt")
barplot(alignment,
names.arg = alignment,
cex.names = 0.7,
col = sequential,
xlab = "Samples",
ylab = "Percent mapped",
xlim = c(0,20),
width = 1))
Thanks!