0

I have this:

fibr <- degs$pathol == "fibrosis"
val01 <- degs$value %in% c(0, 1)

ttest <- t.test(logFC ~ value, data = degs, subset = fibr & val01)
ttest

and I would like to add the results to the box-plot in which have the code:

degs$id <- paste(degs$Symbol, degs$value, sep = "_")
ggplot(degs, aes(x=Symbol, y=logFC, fill=value)) +
    geom_boxplot(
        aes(fill = value),
        position = position_dodge(0.9) 
    ) +
    scale_fill_viridis_d(alpha = 0.6,name = "Fibrosis", labels = c("No", "Yes")) + theme_ipsum(axis_title_just = "center")  +
  theme(axis.title.x = element_blank(),axis.text.x  = element_text(size=14)) 

Is there a nice way to integrate the two, and does it even make sense to do so?

Output of:

dput(head(subset(degs, fibr & val01), 20))

is:

structure(list(experiment = c("FP001RO_15_HI", "FP001RO_15_HI", 
"FP001RO_15_HI", "FP001RO_15_HI", "FP001RO_15_HI", "FP001RO_15_HI", 
"FP001RO_15_HI", "FP001RO_15_HI", "FP001RO_15_HI", "FP001RO_15_HI", 
"FP001RO_15_LOW", "FP001RO_15_LOW", "FP001RO_15_LOW", "FP001RO_15_LOW", 
"FP001RO_15_LOW", "FP001RO_15_LOW", "FP001RO_15_LOW", "FP001RO_15_LOW", 
"FP001RO_15_LOW", "FP001RO_15_LOW"), Human.Gene.entrezID = c("79882", 
"4267", "6237", "23503", "7001", "3482", "7011", "121457", "23646", 
"84962", "84962", "79882", "3482", "7011", "4267", "7001", "121457", 
"23503", "6237", "23646"), Symbol = c("ZC3H14", "CD99", "RRAS", 
"ZFYVE26", "PRDX2", "IGF2R", "TEP1", "IKBIP", "PLD3", "AJUBA", 
"AJUBA", "ZC3H14", "IGF2R", "TEP1", "CD99", "PRDX2", "IKBIP", 
"ZFYVE26", "RRAS", "PLD3"), description = c("zinc finger CCCH-type containing 14", 
"CD99 molecule (Xg blood group)", "RAS related", "zinc finger FYVE-type containing 26", 
"peroxiredoxin 2", "insulin like growth factor 2 receptor", "telomerase associated protein 1", 
"IKBKB interacting protein", "phospholipase D family member 3", 
"ajuba LIM protein", "ajuba LIM protein", "zinc finger CCCH-type containing 14", 
"insulin like growth factor 2 receptor", "telomerase associated protein 1", 
"CD99 molecule (Xg blood group)", "peroxiredoxin 2", "IKBKB interacting protein", 
"zinc finger FYVE-type containing 26", "RAS related", "phospholipase D family member 3"
), score = c(1.966, 2.061, 2.086, 2.093, 2.152, 2.209, 2.304, 
2.1, 2.002, 2.037, 2.037, 1.966, 2.209, 2.304, 2.061, 2.152, 
2.1, 2.093, 2.086, 2.002), type = c("WGGNC", "WGGNC", "WGGNC", 
"WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", 
"WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", "WGGNC", 
"WGGNC", "WGGNC", "WGGNC"), pathol = c("fibrosis", "fibrosis", 
"fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis", 
"fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis", 
"fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis", "fibrosis"
), Probeid = c("192359_at", "652929_at", "361568_at", "314265_at", 
"29338_at", "25151_at", "64523_at", "314730_at", "361527_at", 
"85265_at", "85265_at", "192359_at", "25151_at", "64523_at", 
"652929_at", "29338_at", "314730_at", "314265_at", "361568_at", 
"361527_at"), logFC = c(0.189307395403991, -0.218768611418442, 
-0.172036843631539, 0.126638073051725, 0.125933921576068, 0.197710501024909, 
-0.0983090466626341, -0.164121409539302, 0.179115315008899, -0.322185777058426, 
-0.138594130375549, 0.0369773163930783, -0.0463242231041466, 
0.00120907154880247, -0.0744607340154469, -0.0299324960899258, 
-0.06452289780323, -0.233579732021767, 0.00704698174544466, -0.0249559289699725
), AveExpr = c(8.11893700193941, 8.08783486548433, 7.60120294502047, 
7.99437567047387, 10.5260208588935, 8.29444138846504, 6.06734952233312, 
4.60461244178102, 6.06276854431743, 5.26611859155, 5.35791441489144, 
8.04277196243396, 8.17242402640051, 6.11710858143884, 8.15998880418583, 
10.4480876500605, 4.65441169764906, 7.81426676793712, 7.69074485770897, 
5.96073292232799), t = c(2.06090411061157, -1.64800272058581, 
-1.67484122901572, 1.017602482356, 1.98142623888902, 2.23685416530916, 
-0.7750045573445, -1.60017672898864, 1.74823465840716, -2.26587527980607, 
-1.15739858377159, 0.355719446400545, -0.669661788119842, 0.0104268124984859, 
-0.83263177804617, -0.41945960802557, -0.866027395347389, -1.66891615909237, 
0.0713933088870901, -0.216220585258304), P.Value = c(0.0620048500193615, 
0.125637269682186, 0.120176257489696, 0.329229185026756, 0.0712703696969036, 
0.0453541215773015, 0.45355134490288, 0.135911285618162, 0.106301544980364, 
0.0430523554165742, 0.269237308474993, 0.72811716180726, 0.51553061905244, 
0.991849091092439, 0.421031152995495, 0.68216180440658, 0.403162129613282, 
0.120538997103028, 0.94424015405558, 0.832383970652717), adj.P.Val = c(0.266609942703581, 
0.395711961065005, 0.385926704738747, 0.642358533008832, 0.287100702907388, 
0.224089143535346, 0.741932899727252, 0.413039880873167, 0.360566145997176, 
0.218063075381514, 0.999594589241814, 0.999594589241814, 0.999594589241814, 
0.999594589241814, 0.999594589241814, 0.999594589241814, 0.999594589241814, 
0.956583028638043, 0.999594589241814, 0.999594589241814), B = c(-4.70850210059399, 
-5.33673774869613, -5.29833828529296, -6.10895343062981, -4.83507729732636, 
-4.42051216454706, -6.32558327813216, -5.40420511632374, -5.19143331703487, 
-4.37209059064901, -4.91479672823894, -5.42361975591584, -5.28302890123849, 
-5.4800159426317, -5.17888497410751, -5.40176281489399, -5.1550860929243, 
-4.37464982638808, -5.47777786704639, -5.45913061397151), cpd = c("FP001RO", 
"FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", 
"FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", 
"FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", "FP001RO", 
"FP001RO"), time = c(15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
15, 15, 15, 15, 15, 15, 15, 15, 15, 15), dose = c("HI", "HI", 
"HI", "HI", "HI", "HI", "HI", "HI", "HI", "HI", "LOW", "LOW", 
"LOW", "LOW", "LOW", "LOW", "LOW", "LOW", "LOW", "LOW"), entrezgene_rat = c(192359, 
652929, 361568, 314265, 29338, 25151, 64523, 314730, 361527, 
85265, 85265, 192359, 25151, 64523, 652929, 29338, 314730, 314265, 
361568, 361527), external_gene_name_rat = c("Zc3h14", "Cd99", 
"Rras", "Zfyve26", "Prdx2", "Igf2r", "Tep1", "Ikbip", "Pld3", 
"Ajuba", "Ajuba", "Zc3h14", "Igf2r", "Tep1", "Cd99", "Prdx2", 
"Ikbip", "Zfyve26", "Rras", "Pld3"), external_gene_name_human = c("ZC3H14", 
"CD99", "RRAS", "ZFYVE26", "PRDX2", "IGF2R", "TEP1", "IKBIP", 
"PLD3", "AJUBA", "AJUBA", "ZC3H14", "IGF2R", "TEP1", "CD99", 
"PRDX2", "IKBIP", "ZFYVE26", "RRAS", "PLD3"), entrezGene_probes_human = c("79882_at", 
"4267_at", "6237_at", "23503_at", "7001_at", "3482_at", "7011_at", 
"121457_at", "23646_at", "84962_at", "84962_at", "79882_at", 
"3482_at", "7011_at", "4267_at", "7001_at", "121457_at", "23503_at", 
"6237_at", "23646_at"), inMap_human_withGrey = c(1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), inMap_rat_withGrey = c(1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), variable = structure(c(7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L), .Label = c("Necrosis1", "Necrosis2", "Necrosis3", 
"hyperpl1", "hyperpl2", "hyperpl3", "fibrosis", "hypertrophy1", 
"hypertrophy2", "mitosis1", "mitosis2", "mitosis3", "vacuolation1", 
"vacuolation2", "vacuolation3"), class = "factor"), value = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  

I am unsure how I can make the tastiest integrate into the box-lot simply using the test output which successfully created the result.

Francesca C
  • 177
  • 1
  • 9
  • 1
    check the `ggpubr` or `ggsignif` packages – Roman Apr 22 '22 at 13:49
  • See if [this](https://stackoverflow.com/questions/67402367/adding-p-values-to-ggplot-but-removing-the-line) solves the problem. Also, please post data. Post the output of `dput(head(subset(degs, fibr & val01), 20))` in the question. – Rui Barradas Apr 22 '22 at 14:28
  • @RuiBarradas I just uploaded it. looking at that code from the link, I am unsure what would be the df itself? – Francesca C Apr 27 '22 at 10:56

0 Answers0