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
                Exploring the Dynamics of the Tumor Microenvironment
                by seqadmin




                The complexity of cancer is clearly demonstrated in the diverse ecosystem of the tumor microenvironment (TME). The TME is made up of numerous cell types and its development begins with the changes that happen during oncogenesis. “Genomic mutations, copy number changes, epigenetic alterations, and alternative gene expression occur to varying degrees within the affected tumor cells,” explained Andrea O’Hara, Ph.D., Strategic Technical Specialist at Azenta. “As...
                07-08-2024, 03:19 PM
              • seqadmin
                Exploring Human Diversity Through Large-Scale Omics
                by seqadmin


                In 2003, researchers from the Human Genome Project (HGP) announced the most comprehensive genome to date1. Although the genome wasn’t fully completed until nearly 20 years later2, numerous large-scale projects, such as the International HapMap Project and 1000 Genomes Project, continued the HGP's work, capturing extensive variation and genomic diversity within humans. Recently, newer initiatives have significantly increased in scale and expanded beyond genomics, offering a more detailed...
                06-25-2024, 06:43 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by seqadmin, 07-19-2024, 07:20 AM
              0 responses
              30 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 07-16-2024, 05:49 AM
              0 responses
              42 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 07-15-2024, 06:53 AM
              0 responses
              51 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 07-10-2024, 07:30 AM
              0 responses
              43 views
              0 likes
              Last Post seqadmin  
              Working...
              X