Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aevgup
    Member
    • Jul 2011
    • 17

    #1

    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.
  • blakeoft
    Member
    • Oct 2013
    • 79

    #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

    • aevgup
      Member
      • Jul 2011
      • 17

      #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

      • blakeoft
        Member
        • Oct 2013
        • 79

        #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

        • aevgup
          Member
          • Jul 2011
          • 17

          #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

          • Thias
            Member
            • Mar 2013
            • 45

            #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

            • aevgup
              Member
              • Jul 2011
              • 17

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

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                by SEQadmin2



                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                ...
                10-14-2026, 09:55 AM
              • SEQadmin2
                New Genomics Technologies Take Aim at Long-Standing Limits
                by SEQadmin2


                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                ...
                09-28-2026, 10:25 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 10-22-2026, 11:13 AM
              0 responses
              24 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-22-2026, 10:48 AM
              0 responses
              20 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-15-2026, 10:52 AM
              0 responses
              36 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-14-2026, 05:39 AM
              0 responses
              42 views
              0 reactions
              Last Post SEQadmin2  
              Working...