Unconfigured Ad

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

    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

                    • SEQadmin2
                      Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                      by SEQadmin2


                      Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                      The systematic characterization of the human proteome has
                      ...
                      07-20-2026, 11:48 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-20-2026, 11:10 AM
                    0 responses
                    9 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-13-2026, 10:26 AM
                    0 responses
                    30 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-09-2026, 10:04 AM
                    0 responses
                    41 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-08-2026, 10:08 AM
                    0 responses
                    26 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...