[英]How to make a scatterplot/bubble chart in R including continuous an discrete variables from two matrices
這是另一個答案。 它是相似的,但是與Rawr采取的方法有所不同,主要是因為我假設數據是矩陣(而不是數據幀),並使用了另一個繪圖引擎。
library(reshape2)
library(ggplot2)
#combine the data, as we need to be able to count each occurence of combinations
#assumes data are in matrices. converts to dataframe because of different types
mydat <- data.frame(geno=as.vector(geno),
readcount=as.vector(readcounts))
#remove missings
mydat <- mydat[!is.na(mydat$geno),]
#aggregate using reshape
plotdata <- dcast(geno+readcount~"count",
data=mydat, fun.aggregate = length, value.var="readcount")
#plot
p1 <- ggplot(plotdata, aes(x=readcount,y=geno)) +
geom_point(aes(size=count)) +
scale_x_continuous(breaks=1:3)+
theme_bw()
p1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.