Reputation: 9018
I have a set of data looks like this:
CHROM POS GT DIFF
chr01 integer AG integer
chr01 integer GA integer
chr02 integer CG integer
..
chr22 integer GT integer
chrX integer TC integer
I want to plot POS(x-axis) vs DIFF(y-axis), and I want to group x-axis based on the level of CHROM.
Below is a sample plot I have only for chr01.
I want to have chr02 ... chrX in this plot as well to the right of chr01.
My code is:
my.key <- list(space="right",
border=T,
cex.title=1.2,
title="Legend",
size=10,
text=levels(GT),
fill=T)
xyplot(data$DIFF[data$CHROM=="chr01"]~data$POS[data$CHROM=="chr01"],
xlab = "chr01 -- LCMT0001",
ylab = "Distance -- LCMT0001",
col=GT,
group=GT,
auto.key = my.key,
pch=16,
scales=list(
x = list(alternating=F,tick.number = 8),
y = list(log=10,tick.number=11))
)
Upvotes: 0
Views: 72
Reputation: 67778
You may try ggplot
:
# some sample data
df <- data.frame(CHROM = 1:4,
POS = 1:5,
GT = sample(c("ac", "ag", "at"), 100, replace = TRUE),
DIFF= sample(1:100))
ggplot(data = df, aes(x = POS, y = DIFF, colour = GT)) +
geom_point() +
facet_grid(~ CHROM) +
theme_bw()
Upvotes: 1