내 데이터 플롯여러 플롯 구성은 여기
nmar <- seq (1, 100, 5)
position= rep(nmar, 5)
n = length (nmar)
chr = rep(1:5, each = n)
mapdata <- data.frame (chr, position,
snpname = paste("SNP-", 1:length (position), sep = ""))
mapdata
chr.lab = 1 ; mbar.col = "blue"
layout(matrix(c(1,1,2),nc=1)) # works for two but I need to extend it to
n (which is level of chr = 5)
# plot level 1
mapdata1 <- mapdata[mapdata$chr == 1,]
m <- par()$mar
m[1] <- m[3] <- 0
par(mar=m)
# Set the limits of the plot
plot(mapdata1$position,mapdata1$position-mapdata1$position, type="n",
axes=FALSE,
xlab="", ylab="Chromsome", yaxt="n")
polygon(
c(0,max(mapdata1$position + 0.08 * max(mapdata1$position)),max(mapdata1$position)+
0.08 * max(mapdata1$position),0),
.2*c(-0.3,-0.3,0.3,0.3),
col= mbar.col
)
segments(mapdata1$position, -.3, mapdata1$position, .3)
text(mapdata1$position, -.7, mapdata1$snpname, srt = 90, cex.lab = chr.lab)
text(mapdata1$position, .7, mapdata1$position,cex.lab = chr.lab)
text(0, labels = c("Chr 2"))
2 수준이다
# plot level 2
mapdata2 <- mapdata[mapdata$chr == 2,]
m <- par()$mar
m[1] <- m[3] <- 0
par(mar=m)
# Set the limits of the plot
plot(mapdata2$position,mapdata2$position-mapdata1$position, type="n", axes=FALSE,
xlab="", ylab="Chromsome", yaxt="n")
polygon(
c(0,max(mapdata2$position + 0.08 * max(mapdata2$position)),max(mapdata2$position)+
0.08 * max(mapdata2$position),0),
.2*c(-0.3,-0.3,0.3,0.3),
col= mbar.col
)
segments(mapdata2$position, -.3, mapdata2$position, .3)
text(mapdata2$position, -.7, mapdata2$snpname, srt = 90, cex.lab = chr.lab)
text(mapdata2$position, .7, mapdata2$position,cex.lab = chr.lab)
text(0, labels = c("Chr 2"))
출력
(1) 어떻게 나는 n 레벨을위한 프로세스를 자동화한다. 비슷한 레벨을 ch 레벨 n 레벨로 확장한다. (2) 동일한 스펙을 가진 barsize를 보면 c 교수형, 다른 음모 지역으로 인해 수 있습니다. 모든 플롯을 동일하게 만드는 방법은 무엇입니까?
어떤 특별한 이유 함수가 대신 CHR의 값을 가져 있도록 수정할 수 있을까? ggplot2와 격자는 이러한 종류의 복합 플롯을 쉽게 만들 수있는 솔루션을 제공합니다. 많은 링크를 참조하십시오 http://learnr.wordpress.com/2009/06/28/ggplot2-version-of-figures-in-lattice-multivariate -data-visualization-with-r-part-1/http://learnr.wordpress.com/2009/06/29/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r -part-2/http://learnr.wordpress.com/2009/07/02/ggplot2-version-of-figures-in-lattice-multivariate-data-visualization-with-r-part-3/ –
동의합니다. ggplot2와 격자가 더 좋지만 조작하기가 어렵다고 생각합니까? 아닙니다. – SHRram
일단 ggplot2를 사용하면 매우 쉽게 사용할 수 있습니다. 비록 ggplot2를 선호하지만, ggplot2를 사용하기로 결정한 후에도 ggplot2 또는 lattice로 바꿀만한 가치가 있습니다. –