MA plot
3
0
Entering edit mode
Nathalie ▴ 20
@ab7ad8dd
Last seen 20 months ago
France

Hello, I am a beginner in R studio. I try to do a MAplot after a differential analysis. I try this code but I obtain a message of error. I insert a picture of the dataframe. Could you help me ? I find this code : [https://rpkgs.datanovia.com/ggpubr/reference/ggmaplot.html[1] Thank you very much

Code should be placed in three backticks as shown below

dtf <- read.table("Essai.txt")
diffexp <- dtf

library(geneplotter)
library(ggmatplot)
ggmaplot(diffexp, main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, fc = 2, size = 0.4,
         palette = c("#B31B21", "#1465AC", "darkgray"),
         legend = "top", top = 20,
         font.label = c("bold", 11),
         font.legend = "bold",
         font.main = "bold",
         ggtheme = ggplot2::theme_minimal())


Error in ggmaplot(nana, main = expression("Group 1" %->% "Group 2"), fdr = 0.05,  : 
  could not find function "ggmaplot"
MAplot • 2.8k views
ADD COMMENT
3
Entering edit mode
Basti ▴ 780
@7d45153c
Last seen 8 days ago
France

You need to load (and maybe install) ggpubr because ggmaplot is in this package : library(ggpubr) https://www.rdocumentation.org/packages/ggpubr/versions/0.5.0/topics/ggmaplot

ADD COMMENT
0
Entering edit mode
Nathalie ▴ 20
@ab7ad8dd
Last seen 20 months ago
France

Thank you for your help. I install the package, I change the names of columns (message error). I run the code and I obtain a new message of error.

Error in data$baseMean + 1 : non-numeric argument to binary operator
ADD COMMENT
2
Entering edit mode

This likely has to do with the 1st row in your input; these are the names of the columns, thus characters, and not numbers. Fix this by adding the argument header = TRUE to your call when reading in the data. Thus:

dtf <- read.table("Essai.txt", header = TRUE)

Also note that you have comma's as decimal marks, and whereas dots may be expected.... Check the argument dec of read.table (default is dec = ".").

ADD REPLY
0
Entering edit mode

Thank you for your help. I made the modifications. But I obtain a new error message that I don't understand. Could you help me ?

 dtf <- read.table("Essai.txt", header = TRUE)
str(dtf)``
library(ggpubr) 
library(geneplotter)
library(ggmatplot)
ggmaplot(dtf, main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, fc = 2, size = 0.4,
         palette = c("#B31B21", "#1465AC", "darkgray"),
         legend = "top", top = 20,
         font.label = c("bold", 11),
         font.legend = "bold",
         font.main = "bold",
         ggtheme = ggplot2::theme_minimal())



  > str(dtf)
'data.frame':   24405 obs. of  3 variables:
 $ baseMean      : num  0.05 -0.05 0.17 0.83 -0.03 0 0.17 0 0.17 -0.71 ...
 $ log2FoldChange: num  -0.88 -0.22 0.21 8.17 2.46 -0.18 3.59 4.14 3.25 -2.38 ...
 $ padj          : num  0.04 0.03 0.38 14.6 0.02 0 0.82 0 0.26 0.57 ...
> library(geneplotter)
> library(ggmatplot)
> library(ggmatplot)
> ggmaplot(dtf, main = expression("Group 1" %->% "Group 2"),
+          fdr = 0.05, fc = 2, size = 0.4,
+          palette = c("#B31B21", "#1465AC", "darkgray"),
+          legend = "top", top = 20,
+          font.label = c("bold", 11),
+          font.legend = "bold",
+          font.main = "bold",
+          ggtheme = ggplot2::theme_minimal())
Error in seq.default(0, max(data$mean), 2) : 
  'to' doit ĂȘtre un nombre fini
In addition: Warning message:
In ggmaplot(dtf, main = expression("Group 1" %->% "Group 2"), fdr = 0.05,  :
  NaNs produced
>

> 
ADD REPLY
3
Entering edit mode

Without having a reproducible example, or access to your data, it is almost impossible to help you. Also note that ggpubr is not a Bioconductor package...

After having had a quick look at your code I noticed some strange things in your input: the values are really low for a baseMean..., or do you rather mean baseMeanLog2? Also, a padj of 14.6 (at the 5th row) is impossible.... And what about the gene identifiers?

So please double-check your input file (ideally you would use the DESeq2 object directly instead of a saved txt file), and when you keep having errors I would recommend you run the ggmaplot function on a data set that everyone can reproduce. If errors still occur, then you know something fundamental is wrong, if that goes fine, it confirms it is specific to your input.

## generate some example data
library(DESeq2)
dds <- makeExampleDESeqDataSet(betaSD=4)
dds <- DESeq(dds)
res <- results(dds)

## Create MA plot

    library(ggpubr)

    ggmaplot(res, main = expression("Group 1" %->% "Group 2"),
             fdr = 0.05, fc = 2, size = 0.4,
             palette = c("#B31B21", "#1465AC", "darkgray"),
             legend = "top", top = 20,
             font.label = c("bold", 11),
             font.legend = "bold",
             font.main = "bold",
             ggtheme = ggplot2::theme_minimal())

enter image description here

ADD REPLY
0
Entering edit mode
Nathalie ▴ 20
@ab7ad8dd
Last seen 20 months ago
France

Thank you very much for your help and comments. There is errors in my file. BaseMean is BaseMeanLog2. I don't know how insert a file.

ADD COMMENT
1
Entering edit mode

Yes, some of the values in your input don't make sense.

Yet, since you just started learning below some code to use to read in a tab delimited text file:

# no gene ids included
dtf <- read.table("testinputnoids.txt", header = TRUE)

# with gene ids included in 1st column
dtf2 <- read.table("testinputwithids.txt", header = TRUE, row.names=1)

If you would like to test: these 2 files are available here (for a single download).

ADD REPLY
1
Entering edit mode

Thank you again for your help. It's very nice of you to take the time to help a newbie. I downloaded your files, it will allow me to better understand my errors. I found my mistakes, I will redo everything calmly. I also have the names of the genes I'm going to use.

ADD REPLY

Login before adding your answer.

Traffic: 452 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6