Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Dark plot ???

    Hi! I did a plot with some of my data and the plot was dark. Some ideas?

    Commands were simple,

    d1 <- read.csv("all filter1.csv", header=T)
    plot(d1[,7], d1[,18])

    Somebody knows how can I improve it? Thanks a lot!
    Attached Files

  • #2
    Garbage in, garbage out.

    There may be so many densely packed points on the whole plot, that it appears entirely black.

    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    — Charles Babbage, Passages from the Life of a Philosopher

    Comment


    • #3
      As usual, @dpryan's answer in the other thread is better.

      Still, the plot is so uniformly black, that I'm not sure that even plotting the density will work.

      Comment


      • #4
        I only plotted 2000 points. I don´t think is a dense packed points issue. It must be something else that I don´t understand. I´m just learning bioinformatics making errors, please be patient with me. Thanks

        Comment


        • #5
          The best troubleshooting step in programming is always to simplify your problem.
          You should also examine your data before plotting it.

          Plot less points and check if you can then see the points.
          For example, plot just the first 10 points.
          The plot should not be dark.
          If it is, you're having issues with the rendering of your plot.
          Code:
          plot(d1[,7][1:10], d1[,18][1:10])
          If you've concluded that you don't have any rendering issues, check the number of points you are plotting.
          Code:
          nrow(d1)
          If the number of points is reasonable, check the first few points.
          Code:
          head(d1[,7])
          head(d1[,18])
          For a simple scatter plot, Excel will also work fine.
          Obviously, R opens up a whole world of possibilities, but it definitely takes a bit of time to master.

          Comment


          • #6
            Hi! Thanks for your help again. I figured it out that mi data were "factors" instead of "numerics". So, I did a transformation:

            d1 <- read.csv("all filter1.csv", stringsAsFactors = FALSE, header=T)
            trans<- as.numeric(d1[,7])

            But a warning message appears:

            NAs introduced by coercion

            It replaces all my data different from 0 by NA. So, my plot is a simple point in 0:0.

            How can I solve that??

            Thanks a lot!

            Comment


            • #7
              Hi! Thanks for your help again. I figured it out that mi data were "factors" instead of "numerics". So, I did a transformation:
              This is why I prefer fread from data.table.
              It is much faster, and the default setting are nearly always correct.
              Strings are never read as factors by fread.

              Code:
              library(data.table) # Install it before loading it the first time. install.packages("data.table")
              d1 <- fread("all filter1.csv",data.table = FALSE)
              It replaces all my data different from 0 by NA.
              Are you sure these are not strings of characters?
              Characters will be converted to NA, as illustrated in the following example.

              Code:
              > as.numeric("1")
              [1] 1
              > as.numeric("a")
              [1] NA
              Warning message:
              NAs introduced by coercion
              Check your column first, before plotting it.

              Code:
              head(d1[,7])

              Comment


              • #8
                Hi again. You´re right. Mi data are "characters" after reading the file as you suggested with fread. Numbers different from 0 are replaced with NAs.

                Comment


                • #9
                  Do your numbers have commas in them, by any chance?
                  It's the only problem I can think of.
                  If they do, just replace the commas by periods.

                  Code:
                  > as.numeric("2.1")
                  [1] 2.1
                  > as.numeric("2,1")
                  [1] NA
                  Warning message:
                  NAs introduced by coercion
                  Depending on your locale, it could be the opposite, that is the comma could be the decimal separator, whereas your column could use the period as the column separator.
                  Check in your column whether your decimal separator is a period or a comma.
                  Test in the R console, whether as.numeric will work with the decimal separator you are using. Enter the number between quotes.
                  If you obtain NAs, you have identified your bug.
                  Last edited by blancha; 10-20-2015, 10:11 AM.

                  Comment


                  • #10
                    Done!

                    Yes! you´re right again! I changed commas by dots and it worked!
                    Than you very much, I think I´m loving you right 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
                    25 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-10-2024, 10:19 PM
                    0 responses
                    29 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-10-2024, 09:21 AM
                    0 responses
                    25 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 04-04-2024, 09:00 AM
                    0 responses
                    52 views
                    0 likes
                    Last Post seqadmin  
                    Working...
                    X