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
                Current Approaches to Protein Sequencing
                by seqadmin


                Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
                04-04-2024, 04:25 PM
              • seqadmin
                Strategies for Sequencing Challenging Samples
                by seqadmin


                Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                03-22-2024, 06:39 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by seqadmin, 04-11-2024, 12:08 PM
              0 responses
              18 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-10-2024, 10:19 PM
              0 responses
              22 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-10-2024, 09:21 AM
              0 responses
              17 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-04-2024, 09:00 AM
              0 responses
              49 views
              0 likes
              Last Post seqadmin  
              Working...
              X