p-fold plot
1
0
Entering edit mode
20 months ago
shamza • 0

I want to construct this plot, and I have already performed the DESeq analenter image description hereysis.

This is how the data looks:

Gene    p_val   avg_logFC   pct.1   pct.2   p_val_adj
HLA-B   1.69E-152   0.719935845 0.993   0.988   2.38E-148
VAMP5   2.73E-97    1.137804386 0.87    0.527   3.85E-93
PSME2   6.25E-88    0.820693535 0.965   0.88    8.80E-84
STAT1   1.03E-83    0.890453249 0.859   0.553   1.45E-79
TMSB10  5.93E-76    0.490543615 0.996   0.997   8.35E-72
B2M 1.33E-75    0.37713743  0.998   0.998   1.87E-71
TYMP    2.49E-72    0.906256415 0.953   0.824   3.50E-68
IFITM3  1.49E-69    0.995476345 0.926   0.798   2.10E-65
RARRES3 4.66E-68    0.837395227 0.834   0.559   6.56E-64
ANKRD22 1.14E-67    0.681502637 0.503   0.083   1.61E-63
PSMB9   1.28E-64    0.659830567 0.933   0.8 1.80E-60
WARS    2.04E-62    0.959950859 0.846   0.558   2.87E-58
UBE2L6  1.99E-61    0.605432484 0.862   0.621   2.80E-57
GBP5    2.85E-61    0.793452491 0.611   0.188   4.01E-57
GBP1    1.88E-56    0.814885385 0.762   0.436   2.64E-52
MT2A    5.05E-53    0.848928354 0.806   0.459   7.11E-49
PSMB8   6.69E-53    0.504554991 0.89    0.738   9.40E-49
RPL26   1.06E-52    -0.448016779    0.959   0.985   1.49E-48
SERPINA1    3.82E-51    0.766048263 0.854   0.639   5.38E-47
RPL17   1.05E-49    -0.459168307    0.899   0.979   1.48E-45
CALHM6  3.13E-47    0.820200941 0.862   0.706   4.40E-43
LAP3    6.07E-44    0.53985539  0.9 0.812   8.54E-40
SERPING1    7.96E-44    0.593358466 0.613   0.286   1.12E-39
GBP4    3.46E-43    0.503697693 0.666   0.332   4.86E-39
RPS15A  2.54E-42    -0.339844264    0.98    0.992   3.58E-38
PSME1   3.14E-42    0.386908546 0.948   0.894   4.42E-38
HLA-DQB1    5.91E-42    -0.719268982    0.924   0.941   8.32E-38
HLA-A   2.99E-40    0.345138642 0.991   0.985   4.20E-36
TNFSF10 1.43E-39    0.577723294 0.767   0.48    2.01E-35
DNASE1L3    2.26E-39    -0.997362611    0.192   0.483   3.18E-35
SNX10   4.41E-39    0.514208907 0.775   0.515   6.20E-35
ISG15   1.07E-38    0.535463063 0.66    0.324   1.51E-34
PSMB10  1.17E-38    0.43369206  0.893   0.814   1.65E-34
RPL13   1.78E-38    -0.275473045    0.986   0.994   2.51E-34
SMCO4   3.64E-38    0.509866752 0.797   0.576   5.12E-34
IRF1    4.18E-38    0.560489754 0.856   0.615   5.88E-34
TAP1    1.52E-37    0.447373643 0.772   0.5 2.14E-33
TGM2    1.78E-37    0.354960954 0.334   0.059   2.51E-33
IDO1    2.32E-36    1.058259387 0.417   0.13    3.26E-32
CST3    5.43E-35    -0.576129784    0.987   0.994   7.64E-31
FCER1G  8.22E-35    0.402186485 0.924   0.903   1.16E-30
CXCL9   6.79E-34    1.230192366 0.333   0.076   9.56E-30
GCH1    9.28E-34    0.429635781 0.541   0.238   1.31E-29
CD38    1.86E-33    0.331142465 0.476   0.186   2.61E-29
RPS16   5.35E-32    -0.25358759 0.972   0.979   7.53E-28
DEGs • 932 views
ADD COMMENT
3
Entering edit mode
20 months ago

With ggplot and ggrepel. It only shows the gene name for the top and bottom 10 genes (feel free to modify this in the nth code).

library("tidyverse")
library("ggrepel")

df |>
  dplyr::mutate(
    label=ifelse(
      avg_logFC >= nth(avg_logFC, 10, desc(avg_logFC)) | avg_logFC <= nth(avg_logFC, 10, avg_logFC),
      Gene, NA),
    DEGs=dense_rank(-avg_logFC)) |>
  ggplot(aes(x=DEGs, y=avg_logFC)) +
    geom_point(aes(color=avg_logFC), show.legend=FALSE) +
    geom_text_repel(aes(label=label)) +
    geom_hline(yintercept=0, linetype="dashed")
ADD COMMENT
0
Entering edit mode

Thank you for responding, however, I am running into another problem when I execute this code in R.

Error in UseMethod("mutate") : no applicable method for 'mutate' applied to an object of class "function"

ADD REPLY
0
Entering edit mode

You need to replace df in the code with your data.frame of results.

ADD REPLY
0
Entering edit mode

Hey, I did change the df with my data frame however, I am still getting an error. The error is as follows:

Error in dplyr::mutate(): ℹ In argument: label = ifelse(...). Caused by error: ! unable to find an inherited method for function ‘desc’ for signature ‘"numeric"’ Run rlang::last_trace() to see where the error occurred.

ADD REPLY

Login before adding your answer.

Traffic: 1986 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