0

enter image description here

I have a data.frame with X and Y coordinate values. X axis is position information and Y axis is log ratio values. The points are colored based log ratio values(green > 0.25 , -0.25 < grey < 0.25, and red < -0.25). The orange dashed horizontal lines are log2 values of 0.58, 0, and -1.

A circular binary segmentation algorithm segments changes in log ratio, indicated by horizontal blue line. In the image attached one can see several segments, most if it close to log2 of 0. Close to the left end of the figure are small blue segment with log value close to 0.58, and a much smaller (almost invisible because of surrounding red points) blue segment at log value close to -1 (right edge of plot). I have x and y coordinates of these blue segments in another data.frame. I want to achieve the following

1) add circles bounding these blue segments above -0.70 < log2 > 0.50. This helps in identifying small segments that could be missed 2) Add transparent colors to these circles using alpha values so that the blue segment is seen 3) The size of the circle would be based on the width of these blue segments.

I am also open to other ideas of highligting these blue segments at -0.70 < log2 > 0.5. Maybe I should suppress plotting the points (green and red) where these blue segments are found. I am using R to make this plot. Appreciate the help.

This was the code used: There are two df objects. The df(X) contains Chr.no, Chr.Start, Chr.End and Log2. The df(Y) is similar, but different col.names such as loc. start, and loc. end. And instead of Log2, they have seg.mean values

for (i in 1:25)  {       # Plot each chromosome separately

  plot(X[which(X$Chr.No ==i),"Chr.Start"], X[which(X$Chr.No ==i),"Log2"], ylim=c(-4.0,4.0), col=X[which(X$Chr.No ==i),"Color"], pch=16, cex=0.4, ylab="Log2", xlab="Genomic Position", main= paste("KCL:180522_SS", "chromosome", i, sep=" "))
  abline(h=c(-1,0,log2(3/2)), lty=2, col="chocolate")
  xleft  = Y[which(Y$Chr.No ==i),"loc.start"]            # Left limit of the blue horizontal line
  xright = Y[which(Y$Chr.No ==i),"loc.end"]              # Right limit of the blue horizontal line
  ybottom= Y[which(Y$Chr.No ==i),"seg.mean"] - 0.010     # Adding thickness to the "seg.mean"
  ytop   = Y[which(Y$Chr.No ==i),"seg.mean"] + 0.010     # Adding thickness to the "seg.mean"
  rect(xleft=xleft, ybottom=ybottom, xright=xright, ytop=ytop, col="blue", border="blue")
}

@Dwin Yes, "Color" is a vector of "lightgreen", "grey" and "red". These are the color information for the pch=16 in the plot(x,y). I do not want to modify the pch=16 points. The horizontal "blue" line segments are added by the 'rect', and they span many pch=16 points. As you can see there are many "blue" segments, some very small and some large in length that differ in their log2 values.This is what I want to bound with a filled transparent circle. Not all "blue" segments, but only the ones where the "blue" segment 0.25< log2 > 0.25. In this figure the smaller "blue" segments are close to the edges of the plot, and since they are difficult to spot, I want to highlight them with a filled circle around them. Please let me know if I am still not clear. Thanks

2
  • The code use to make this plot might have clues regarding which of the three graphics systems was in use. That information is needed because they have different ways of setting user-coordinates. Commented Sep 16, 2012 at 16:23
  • @Dwin added the code used. Thanks for taking a look Commented Sep 25, 2012 at 19:41

1 Answer 1

0

(Deleted incorrect method based on guess about the manner in which the blue points (which were really segments) were being constructed.)

Edit: With the new information I would suggest drawing ordinary "points", i.e, open circles at the x-vector formed by (xleft+xright)/2 and the y-vector using ytop (which should be the same as ybottom) each for the selected ytop values that meet your criteria. You would make a logical vectors to select each of these vectors. So:

selvec <- ytop < -0.70 | ytop > 0.5
points ( x= (xleft[selvec]+xright[selvec])/2, y= ytop[selvec], cex =1.5, col="blue")

You could also use transparency if you used the rgb() function to create a color with transparency:

points ( x= (xleft[selvec]+xright[selvec])/2, y= ytop[selvec], cex = 2, col=rgb(0, 0, 1, 0.3) )

.... should give you transparent circles if your output device supports it.

Sign up to request clarification or add additional context in comments.

6 Comments

thank you for the code. I see how you code would work, but I think I did not make my point clear. Please see edits added below my question.
Ah. I understand. Shouldn't be that difficult to address. Won't be able to get to it in the next hour, though.
please take your time. I have the xleft, xright and the ytop, ybottom for these "blue" segments.
thanks..how do I ajust the cex to match the length of the "blue" segment. They may have different lengths.
This project has remained highly hypothetical because of your failure to include a test case that illustrates the various features you need to have addressed. I'm not planning on pursuing without sample data and code from which to do testing of my hypotheses..
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.