Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Marcos Lancia
    Member
    • Apr 2015
    • 31

    #1

    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
  • blancha
    Senior Member
    • May 2013
    • 367

    #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

    • blancha
      Senior Member
      • May 2013
      • 367

      #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

      • Marcos Lancia
        Member
        • Apr 2015
        • 31

        #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

        • blancha
          Senior Member
          • May 2013
          • 367

          #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

          • Marcos Lancia
            Member
            • Apr 2015
            • 31

            #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

            • blancha
              Senior Member
              • May 2013
              • 367

              #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

              • Marcos Lancia
                Member
                • Apr 2015
                • 31

                #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

                • blancha
                  Senior Member
                  • May 2013
                  • 367

                  #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

                  • Marcos Lancia
                    Member
                    • Apr 2015
                    • 31

                    #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

                    • kinpict.com
                      Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
                      by kinpict.com
                      The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
                      Today, 06:37 PM
                    • SEQadmin2
                      16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
                      by SEQadmin2





                      NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
                      10-30-2026, 06:46 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by SEQadmin2, 11-12-2026, 07:59 AM
                    0 responses
                    27 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 11-05-2026, 09:25 AM
                    0 responses
                    35 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 11-03-2026, 11:54 AM
                    2 responses
                    56 views
                    0 reactions
                    Last Post kinpict.com  
                    Started by SEQadmin2, 10-28-2026, 09:57 AM
                    0 responses
                    175 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...