Unconfigured Ad

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

    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

              • mylaser
                Reply to Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by mylaser
                Kheloyar – Everything You Need to Know About Kheloyaar Login and Kheoyar Id
                If you are looking for an online gaming platform that offers a user-friendly experience, Kheloyar has become a name that many users search for. Whether you're interested in creating a new account, accessing your dashboard through Kheloyaar Login, or learning how to obtain a Kheoyar Id, understanding the platform's features and account process is essential.
                This guide explains everything you need to know about...
                Yesterday, 01:13 AM
              • SEQadmin2
                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by SEQadmin2



                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                ...
                07-09-2026, 11:10 AM
              • SEQadmin2
                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                by SEQadmin2



                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                07-08-2026, 05:17 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 07-09-2026, 10:04 AM
              0 responses
              22 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-08-2026, 10:08 AM
              0 responses
              14 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-07-2026, 11:05 AM
              0 responses
              33 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-02-2026, 11:08 AM
              0 responses
              31 views
              0 reactions
              Last Post SEQadmin2  
              Working...