Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plotting in R

    Hi Everyone,

    I am trying to plot a histogram in R using this command which is serving my purpose

    x <- read.table(file="cov.txt",header =FALSE)
    When you look at the graph(see attached) then from 715 to 777 is my CODING REGION. I want to make a rectangular bar from position 715-777 and place it on the top of the graph. How can I do it

    I wrote this and try to add lines or points but was not able to do it
    firstCodonCdr1 = 239
    lastCodonCdr1 = 259
    cdr1NTs = ((firstCodonCdr1-1)*3+1)3*lastCodonCdr1)
    cdrPositions = cdr1NTs

    Any help !!

    Thanks
    Attached Files
    Last edited by aevgup; 04-25-2014, 10:41 AM.

  • #2
    I think you want to use the polygon function. See ?polygon to look at the help info. Basically:
    Code:
    polygon(x,y,col)
    where x is the vector containing x coordinates of the vertices, y is y vertices and col is the color of the polygon. I think you'll plot your histogram, and then polygon() right after it. So it'll look like:
    Code:
    > hist(data)
    > polygon(x,y,col)
    Last edited by blakeoft; 04-25-2014, 10:51 AM.

    Comment


    • #3
      plotting in R

      Hi I used this code
      x <- read.table(file="cov.txt",header =FALSE)

      firstCodonCdr1 = 239
      lastCodonCdr1 = 259
      cdr1NTs = ((firstCodonCdr1-1)*3+1)3*lastCodonCdr1)
      cdrPositions = cdr1NTs

      plot(x$V2,x$V3,type="h",col="blue")
      r = rep(50,63) # to make 63 times 50 to occur so that it matches length of x
      par(new=TRUE)

      polygon(cdrPositions,r,col="red")

      No change happens in the graph.

      I am attaching the cov.txt file too

      I have been trying points and lines too but no luck!!

      THanks
      Attached Files

      Comment


      • #4
        This looks terrible, but I just did
        Code:
        > x <- read.table(file="cov.txt",header =FALSE)
        > plot(x$V2,x$V3,type="h",col="blue")
        > polygon(c(715,777,777,715),c(40,40,45,45), col="blue")
        and got this picture. You can change the coordinates of the box if you want so that it doesn't look as bad, and also, the color might need some work. I think you can do it like col = rgb(a,b,c) where a b and c are the red blue and green color values.
        Attached Files

        Comment


        • #5
          Thanks for the reply. Your answer gave me another way to do it. How about this
          x <- read.table(file="cov.txt",header =FALSE)
          plot(x$V2,x$V3,type="h",col="blue")
          lines(c(715,777),c(45,45),col="red",lwd=8)
          Regards
          Attached Files

          Comment


          • #6
            Seems your problem is already solved, but in case you have 5o plot similar data in future again, I recommend the Gviz package on Bioconductor, which can be used to output beautiful plots for NGS-data.

            Comment


            • #7
              Hi,
              Thanks for letting me know about the package. I am trying this package now

              Comment

              Latest Articles

              Collapse

              • seqadmin
                New Genomics Tools and Methods Shared at AGBT 2025
                by seqadmin


                This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

                The Headliner
                The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
                03-03-2025, 01:39 PM
              • seqadmin
                Investigating the Gut Microbiome Through Diet and Spatial Biology
                by seqadmin




                The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
                02-24-2025, 06:31 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by seqadmin, 03-03-2025, 01:15 PM
              0 responses
              179 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 02-28-2025, 12:58 PM
              0 responses
              275 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 02-24-2025, 02:48 PM
              0 responses
              661 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 02-21-2025, 02:46 PM
              0 responses
              268 views
              0 likes
              Last Post seqadmin  
              Working...
              X