I would like to recreate the following plot:
But instead of weeks I have cycles on the x axis and I want to facet it according to responders and non responders. therefore I used the following script:
ggplot(delta, aes(x = cycle, y = change, color = ID))
geom_abline(slope=0, intercept=20, col = "black", lty=2)
geom_abline(slope=0, intercept=-30, col = "black", lty=2)
geom_point( aes( size=1), na.rm = TRUE)
geom_line()
labs(y="% Change from Baseline", x="Cycle",
title="4. Spider Plot for MYD88 VAF")
facet_wrap(~status)
scale_color_brewer(palette="Paired")
theme(legend.title = element_text(color = "black", size = 8, face="bold"),
legend.text = element_text(color = "blue", size = 7)
However it gives me a plot that is faceted but with only dots. And I calculated percent change from baseline and added it to the dataframe. What am I doing wrong?
Here is my data:
> dput(delta)
structure(list(ID = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 17L,
17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 20L, 20L,
20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, 23L,
23L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L,
27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L), .Label = c("1",
"2", "5", "7", "13", "14", "15", "17", "18", "19", "20", "22",
"23", "24", "25", "27", "29", "30", "32", "33", "34", "35", "39",
"41", "42", "45", "46", "48", "52"), class = "factor"), BS = c(24.16,
NA, NA, NA, 4.51, NA, NA, NA, 12.72, NA, NA, NA, 30.94, NA, NA,
NA, 1.64, NA, NA, NA, 9.36, NA, NA, NA, 0.27, NA, NA, NA, 1.28,
NA, NA, NA, 0.36, NA, NA, NA, 1.05, NA, NA, NA, 0.06, NA, NA,
NA, 6.96, NA, NA, NA, 0.13, NA, NA, NA, 0.36, NA, NA, NA, 0.6,
NA, NA, NA, 0.23, NA, NA, NA, 0.92, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 0.42, NA, NA, NA, 3.79, NA, NA,
NA, 0.52, NA, NA, NA, 0.4, NA, NA, NA, 0.78, NA, NA, NA, 1.57,
NA, NA, NA, 1.42, NA, NA, NA, 4.76, NA, NA, NA, 1.05, NA, NA,
NA), C4 = c(2.4, NA, NA, NA, 3.06, NA, NA, NA, 0.15, NA, NA,
NA, 0.37, NA, NA, NA, NA, NA, NA, NA, 1.66, NA, NA, NA, 0.02,
NA, NA, NA, 0.45, NA, NA, NA, 6.13, NA, NA, NA, 0.01, NA, NA,
NA, 0.21, NA, NA, NA, 2.77, NA, NA, NA, 0.46, NA, NA, NA, 0.14,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.41, NA, NA, NA,
1.4, NA, NA, NA, 2.23, NA, NA, NA, 2.82, NA, NA, NA, 0.17, NA,
NA, NA, 0.17, NA, NA, NA, 1.11, NA, NA, NA, 0.32, NA, NA, NA,
0.08, NA, NA, NA, 0, NA, NA, NA, 0.1, NA, NA, NA, 2.47, NA, NA,
NA, 0.88, NA, NA, NA), C8 = c(0, NA, NA, NA, 3.42, NA, NA, NA,
0, NA, NA, NA, 1.13, NA, NA, NA, 0.77, NA, NA, NA, 3.35, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA,
NA, NA, 0.27, NA, NA, NA, 0.14, NA, NA, NA, 0.57, NA, NA, NA,
0, NA, NA, NA, 0.13, NA, NA, NA, 0.93, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.73, NA, NA, NA, 0, NA, NA, NA, 2.5, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, 2.34, NA, NA, NA, 0, NA,
NA, NA), EOT = c(0.62, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, 0, NA, NA, NA, 1.74, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.09, NA, NA, NA, 0, NA, NA, NA, NA, NA,
NA, NA, 5.89, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, 0, NA,
NA, NA, NA, NA, NA, NA, 0.95, NA, NA, NA, 0, NA, NA, NA, 0.79,
NA, NA, NA, 2.03, NA, NA, NA, NA, NA, NA, NA, 1.62, NA, NA, NA,
NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, 0.45, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.1, NA, NA, NA), `%D C4` = c(-0.900662251655629,
NA, NA, NA, -0.321507760532151, NA, NA, NA, -0.988207547169811,
NA, NA, NA, -0.988041370394312, NA, NA, NA, NA, NA, NA, NA, -0.822649572649573,
NA, NA, NA, -0.925925925925926, NA, NA, NA, -0.6484375, NA, NA,
NA, 16.0277777777778, NA, NA, NA, -0.990476190476191, NA, NA,
NA, 2.5, NA, NA, NA, -0.602011494252873, NA, NA, NA, 2.53846153846154,
NA, NA, NA, -0.611111111111111, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1.6195652173913, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, -0.595238095238095, NA, NA, NA, -0.955145118733509,
NA, NA, NA, 1.13461538461538, NA, NA, NA, -0.2, NA, NA, NA, -0.897435897435897,
NA, NA, NA, -1, NA, NA, NA, -0.929577464788732, NA, NA, NA, -0.48109243697479,
NA, NA, NA, -0.161904761904762, NA, NA, NA), `%D C8` = c(-1,
NA, NA, NA, -0.241685144124168, NA, NA, NA, -1, NA, NA, NA, -0.963477698771816,
NA, NA, NA, -0.530487804878049, NA, NA, NA, -0.642094017094017,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -1,
NA, NA, NA, -0.55, NA, NA, NA, -0.391304347826087, NA, NA, NA,
-0.380434782608696, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, 0.403846153846154,
NA, NA, NA, -1, NA, NA, NA, 2.2051282051282, NA, NA, NA, -1,
NA, NA, NA, -1, NA, NA, NA, -0.508403361344538, NA, NA, NA, -1,
NA, NA, NA), `%D EOT` = c(-0.974337748344371, NA, NA, NA, NA,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, 0.0609756097560976,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.75,
NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.153735632183908,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA,
NA, NA, NA, 0.0326086956521738, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.572559366754617,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.713375796178344,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.904761904761905,
NA, NA, NA), Response = c("PR", NA, NA, NA, "MR", NA, NA, NA,
"CR", NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA,
NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA,
"PD", NA, NA, NA, "VGPR", NA, NA, NA, "VGPR", NA, NA, NA, "MR",
NA, NA, NA, "PR", NA, NA, NA, "PR", NA, NA, NA, "PD", NA, NA,
NA, "PD", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR", NA, NA,
NA, "MR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA, NA, NA),
status = c("Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder"), cycle = c("BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT"), MYD88_VAF = c(24.16, 2.4, 0, 0.62, 4.51, 3.06,
3.42, NA, 12.72, 0.15, 0, 0, 30.94, 0.37, 1.13, 0, 1.64,
NA, 0.77, 1.74, 9.36, 1.66, 3.35, NA, 0.27, 0.02, 0, 0, 1.28,
0.45, 0, NA, 0.36, 6.13, NA, 0.09, 1.05, 0.01, NA, 0, 0.06,
0.21, NA, NA, 6.96, 2.77, NA, 5.89, 0.13, 0.46, NA, NA, 0.36,
0.14, 0, 0, 0.6, NA, 0.27, 0, 0.23, NA, 0.14, NA, 0.92, 2.41,
0.57, 0.95, NA, 1.4, 0, 0, NA, 2.23, 0.13, 0.79, NA, 2.82,
0.93, 2.03, 0.42, 0.17, 0, NA, 3.79, 0.17, NA, 1.62, 0.52,
1.11, 0.73, NA, 0.4, 0.32, 0, 0, 0.78, 0.08, 2.5, NA, 1.57,
0, 0, 0.45, 1.42, 0.1, 0, NA, 4.76, 2.47, 2.34, NA, 1.05,
0.88, 0, 0.1), change = c(0, -21.76, -24.16, -23.54, 0, -1.45,
-1.09, NA, 0, -12.57, -12.72, -12.72, 0, -30.57, -29.81,
-30.94, 0, NA, -0.87, 0.1, 0, -7.7, -6.01, NA, 0, -0.25,
-0.27, -0.27, 0, -0.83, -1.28, NA, 0, 5.77, NA, -0.27, 0,
-1.04, NA, -1.05, 0, 0.15, NA, NA, 0, -4.19, NA, -1.07, 0,
0.33, NA, NA, 0, -0.22, -0.36, -0.36, 0, NA, -0.33, -0.6,
0, NA, -0.09, NA, 0, 1.49, -0.35, 0.0299999999999999, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, -0.25, -0.42,
NA, 0, -3.62, NA, -2.17, 0, 0.59, 0.21, NA, 0, -0.08, -0.4,
-0.4, 0, -0.7, 1.72, NA, 0, -1.57, -1.57, -1.12, 0, -1.32,
-1.42, NA, 0, -2.29, -2.42, NA, 0, -0.17, -1.05, -0.95)), row.names = c(NA,
-116L), groups = structure(list(ID = c(1, 2, 5, 7, 13, 14, 15,
17, 18, 19, 20, 22, 23, 24, 25, 27, 29, 30, 32, 33, 34, 35, 39,
41, 42, 45, 46, 48, 52), .rows = list(1:4, 5:8, 9:12, 13:16,
17:20, 21:24, 25:28, 29:32, 33:36, 37:40, 41:44, 45:48, 49:52,
53:56, 57:60, 61:64, 65:68, 69:72, 73:76, 77:80, 81:84, 85:88,
89:92, 93:96, 97:100, 101:104, 105:108, 109:112, 113:116)), row.names = c(NA,
-29L), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"))
CodePudding user response:
I've added group = ID
to get the line (as cycle
is not numeric).
To connect points when there are gaps in the cycles, i.e. when change
is NA
, then start with drop_na
per the second plot below. Also, you could use geom_hline
instead of geom_abline
then it's not necessary to specify the slope (also in the second plot example).
(If you want the legends, remove legend.position = "none"
.)
library(tidyverse)
# Sample data
delta <- structure(list(
ID = structure(c(
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 17L,
17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 20L, 20L,
20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, 23L,
23L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L,
27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L
), .Label = c(
"1",
"2", "5", "7", "13", "14", "15", "17", "18", "19", "20", "22",
"23", "24", "25", "27", "29", "30", "32", "33", "34", "35", "39",
"41", "42", "45", "46", "48", "52"
), class = "factor"), BS = c(
24.16,
NA, NA, NA, 4.51, NA, NA, NA, 12.72, NA, NA, NA, 30.94, NA, NA,
NA, 1.64, NA, NA, NA, 9.36, NA, NA, NA, 0.27, NA, NA, NA, 1.28,
NA, NA, NA, 0.36, NA, NA, NA, 1.05, NA, NA, NA, 0.06, NA, NA,
NA, 6.96, NA, NA, NA, 0.13, NA, NA, NA, 0.36, NA, NA, NA, 0.6,
NA, NA, NA, 0.23, NA, NA, NA, 0.92, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 0.42, NA, NA, NA, 3.79, NA, NA,
NA, 0.52, NA, NA, NA, 0.4, NA, NA, NA, 0.78, NA, NA, NA, 1.57,
NA, NA, NA, 1.42, NA, NA, NA, 4.76, NA, NA, NA, 1.05, NA, NA,
NA
), C4 = c(
2.4, NA, NA, NA, 3.06, NA, NA, NA, 0.15, NA, NA,
NA, 0.37, NA, NA, NA, NA, NA, NA, NA, 1.66, NA, NA, NA, 0.02,
NA, NA, NA, 0.45, NA, NA, NA, 6.13, NA, NA, NA, 0.01, NA, NA,
NA, 0.21, NA, NA, NA, 2.77, NA, NA, NA, 0.46, NA, NA, NA, 0.14,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.41, NA, NA, NA,
1.4, NA, NA, NA, 2.23, NA, NA, NA, 2.82, NA, NA, NA, 0.17, NA,
NA, NA, 0.17, NA, NA, NA, 1.11, NA, NA, NA, 0.32, NA, NA, NA,
0.08, NA, NA, NA, 0, NA, NA, NA, 0.1, NA, NA, NA, 2.47, NA, NA,
NA, 0.88, NA, NA, NA
), C8 = c(
0, NA, NA, NA, 3.42, NA, NA, NA,
0, NA, NA, NA, 1.13, NA, NA, NA, 0.77, NA, NA, NA, 3.35, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA,
NA, NA, 0.27, NA, NA, NA, 0.14, NA, NA, NA, 0.57, NA, NA, NA,
0, NA, NA, NA, 0.13, NA, NA, NA, 0.93, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.73, NA, NA, NA, 0, NA, NA, NA, 2.5, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, 2.34, NA, NA, NA, 0, NA,
NA, NA
), EOT = c(
0.62, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, 0, NA, NA, NA, 1.74, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.09, NA, NA, NA, 0, NA, NA, NA, NA, NA,
NA, NA, 5.89, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, 0, NA,
NA, NA, NA, NA, NA, NA, 0.95, NA, NA, NA, 0, NA, NA, NA, 0.79,
NA, NA, NA, 2.03, NA, NA, NA, NA, NA, NA, NA, 1.62, NA, NA, NA,
NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, 0.45, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.1, NA, NA, NA
), `%D C4` = c(
-0.900662251655629,
NA, NA, NA, -0.321507760532151, NA, NA, NA, -0.988207547169811,
NA, NA, NA, -0.988041370394312, NA, NA, NA, NA, NA, NA, NA, -0.822649572649573,
NA, NA, NA, -0.925925925925926, NA, NA, NA, -0.6484375, NA, NA,
NA, 16.0277777777778, NA, NA, NA, -0.990476190476191, NA, NA,
NA, 2.5, NA, NA, NA, -0.602011494252873, NA, NA, NA, 2.53846153846154,
NA, NA, NA, -0.611111111111111, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1.6195652173913, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, -0.595238095238095, NA, NA, NA, -0.955145118733509,
NA, NA, NA, 1.13461538461538, NA, NA, NA, -0.2, NA, NA, NA, -0.897435897435897,
NA, NA, NA, -1, NA, NA, NA, -0.929577464788732, NA, NA, NA, -0.48109243697479,
NA, NA, NA, -0.161904761904762, NA, NA, NA
), `%D C8` = c(
-1,
NA, NA, NA, -0.241685144124168, NA, NA, NA, -1, NA, NA, NA, -0.963477698771816,
NA, NA, NA, -0.530487804878049, NA, NA, NA, -0.642094017094017,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -1,
NA, NA, NA, -0.55, NA, NA, NA, -0.391304347826087, NA, NA, NA,
-0.380434782608696, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, 0.403846153846154,
NA, NA, NA, -1, NA, NA, NA, 2.2051282051282, NA, NA, NA, -1,
NA, NA, NA, -1, NA, NA, NA, -0.508403361344538, NA, NA, NA, -1,
NA, NA, NA
), `%D EOT` = c(
-0.974337748344371, NA, NA, NA, NA,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, 0.0609756097560976,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.75,
NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.153735632183908,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA,
NA, NA, NA, 0.0326086956521738, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.572559366754617,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.713375796178344,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.904761904761905,
NA, NA, NA
), Response = c(
"PR", NA, NA, NA, "MR", NA, NA, NA,
"CR", NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA,
NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA,
"PD", NA, NA, NA, "VGPR", NA, NA, NA, "VGPR", NA, NA, NA, "MR",
NA, NA, NA, "PR", NA, NA, NA, "PR", NA, NA, NA, "PD", NA, NA,
NA, "PD", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR", NA, NA,
NA, "MR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA, NA, NA
),
status = c(
"Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder"
), cycle = c(
"BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT"
), MYD88_VAF = c(
24.16, 2.4, 0, 0.62, 4.51, 3.06,
3.42, NA, 12.72, 0.15, 0, 0, 30.94, 0.37, 1.13, 0, 1.64,
NA, 0.77, 1.74, 9.36, 1.66, 3.35, NA, 0.27, 0.02, 0, 0, 1.28,
0.45, 0, NA, 0.36, 6.13, NA, 0.09, 1.05, 0.01, NA, 0, 0.06,
0.21, NA, NA, 6.96, 2.77, NA, 5.89, 0.13, 0.46, NA, NA, 0.36,
0.14, 0, 0, 0.6, NA, 0.27, 0, 0.23, NA, 0.14, NA, 0.92, 2.41,
0.57, 0.95, NA, 1.4, 0, 0, NA, 2.23, 0.13, 0.79, NA, 2.82,
0.93, 2.03, 0.42, 0.17, 0, NA, 3.79, 0.17, NA, 1.62, 0.52,
1.11, 0.73, NA, 0.4, 0.32, 0, 0, 0.78, 0.08, 2.5, NA, 1.57,
0, 0, 0.45, 1.42, 0.1, 0, NA, 4.76, 2.47, 2.34, NA, 1.05,
0.88, 0, 0.1
), change = c(
0, -21.76, -24.16, -23.54, 0, -1.45,
-1.09, NA, 0, -12.57, -12.72, -12.72, 0, -30.57, -29.81,
-30.94, 0, NA, -0.87, 0.1, 0, -7.7, -6.01, NA, 0, -0.25,
-0.27, -0.27, 0, -0.83, -1.28, NA, 0, 5.77, NA, -0.27, 0,
-1.04, NA, -1.05, 0, 0.15, NA, NA, 0, -4.19, NA, -1.07, 0,
0.33, NA, NA, 0, -0.22, -0.36, -0.36, 0, NA, -0.33, -0.6,
0, NA, -0.09, NA, 0, 1.49, -0.35, 0.0299999999999999, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, -0.25, -0.42,
NA, 0, -3.62, NA, -2.17, 0, 0.59, 0.21, NA, 0, -0.08, -0.4,
-0.4, 0, -0.7, 1.72, NA, 0, -1.57, -1.57, -1.12, 0, -1.32,
-1.42, NA, 0, -2.29, -2.42, NA, 0, -0.17, -1.05, -0.95
)
), row.names = c(
NA,
-116L
), groups = structure(list(ID = c(
1, 2, 5, 7, 13, 14, 15,
17, 18, 19, 20, 22, 23, 24, 25, 27, 29, 30, 32, 33, 34, 35, 39,
41, 42, 45, 46, 48, 52
), .rows = list(
1:4, 5:8, 9:12, 13:16,
17:20, 21:24, 25:28, 29:32, 33:36, 37:40, 41:44, 45:48, 49:52,
53:56, 57:60, 61:64, 65:68, 69:72, 73:76, 77:80, 81:84, 85:88,
89:92, 93:96, 97:100, 101:104, 105:108, 109:112, 113:116
)), row.names = c(
NA,
-29L
), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c(
"grouped_df",
"tbl_df", "tbl", "data.frame"
))
ggplot(delta, aes(x = cycle, y = change, color = ID, group = ID))
geom_abline(slope = 0, intercept = 20, col = "black", lty = 2)
geom_abline(slope = 0, intercept = -30, col = "black", lty = 2)
geom_point(aes(size = 1), na.rm = TRUE)
geom_line()
labs(
y = "% Change from Baseline", x = "Cycle",
title = "4. Spider Plot for MYD88 VAF"
)
facet_wrap(~status)
scale_color_brewer(palette = "Paired")
theme(
legend.title = element_text(color = "black", size = 8, face = "bold"),
legend.text = element_text(color = "blue", size = 7),
legend.position = "none"
)
Created on 2022-07-18 by the reprex package (v2.0.1)
library(tidyverse)
# Sample data
delta <- structure(list(
ID = structure(c(
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L,
7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L, 10L, 10L,
10L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L,
14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 17L,
17L, 17L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 20L, 20L,
20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, 23L,
23L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L,
27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L
), .Label = c(
"1",
"2", "5", "7", "13", "14", "15", "17", "18", "19", "20", "22",
"23", "24", "25", "27", "29", "30", "32", "33", "34", "35", "39",
"41", "42", "45", "46", "48", "52"
), class = "factor"), BS = c(
24.16,
NA, NA, NA, 4.51, NA, NA, NA, 12.72, NA, NA, NA, 30.94, NA, NA,
NA, 1.64, NA, NA, NA, 9.36, NA, NA, NA, 0.27, NA, NA, NA, 1.28,
NA, NA, NA, 0.36, NA, NA, NA, 1.05, NA, NA, NA, 0.06, NA, NA,
NA, 6.96, NA, NA, NA, 0.13, NA, NA, NA, 0.36, NA, NA, NA, 0.6,
NA, NA, NA, 0.23, NA, NA, NA, 0.92, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 0.42, NA, NA, NA, 3.79, NA, NA,
NA, 0.52, NA, NA, NA, 0.4, NA, NA, NA, 0.78, NA, NA, NA, 1.57,
NA, NA, NA, 1.42, NA, NA, NA, 4.76, NA, NA, NA, 1.05, NA, NA,
NA
), C4 = c(
2.4, NA, NA, NA, 3.06, NA, NA, NA, 0.15, NA, NA,
NA, 0.37, NA, NA, NA, NA, NA, NA, NA, 1.66, NA, NA, NA, 0.02,
NA, NA, NA, 0.45, NA, NA, NA, 6.13, NA, NA, NA, 0.01, NA, NA,
NA, 0.21, NA, NA, NA, 2.77, NA, NA, NA, 0.46, NA, NA, NA, 0.14,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.41, NA, NA, NA,
1.4, NA, NA, NA, 2.23, NA, NA, NA, 2.82, NA, NA, NA, 0.17, NA,
NA, NA, 0.17, NA, NA, NA, 1.11, NA, NA, NA, 0.32, NA, NA, NA,
0.08, NA, NA, NA, 0, NA, NA, NA, 0.1, NA, NA, NA, 2.47, NA, NA,
NA, 0.88, NA, NA, NA
), C8 = c(
0, NA, NA, NA, 3.42, NA, NA, NA,
0, NA, NA, NA, 1.13, NA, NA, NA, 0.77, NA, NA, NA, 3.35, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA,
NA, NA, 0.27, NA, NA, NA, 0.14, NA, NA, NA, 0.57, NA, NA, NA,
0, NA, NA, NA, 0.13, NA, NA, NA, 0.93, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.73, NA, NA, NA, 0, NA, NA, NA, 2.5, NA,
NA, NA, 0, NA, NA, NA, 0, NA, NA, NA, 2.34, NA, NA, NA, 0, NA,
NA, NA
), EOT = c(
0.62, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, 0, NA, NA, NA, 1.74, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA,
NA, NA, NA, NA, NA, 0.09, NA, NA, NA, 0, NA, NA, NA, NA, NA,
NA, NA, 5.89, NA, NA, NA, NA, NA, NA, NA, 0, NA, NA, NA, 0, NA,
NA, NA, NA, NA, NA, NA, 0.95, NA, NA, NA, 0, NA, NA, NA, 0.79,
NA, NA, NA, 2.03, NA, NA, NA, NA, NA, NA, NA, 1.62, NA, NA, NA,
NA, NA, NA, NA, 0, NA, NA, NA, NA, NA, NA, NA, 0.45, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.1, NA, NA, NA
), `%D C4` = c(
-0.900662251655629,
NA, NA, NA, -0.321507760532151, NA, NA, NA, -0.988207547169811,
NA, NA, NA, -0.988041370394312, NA, NA, NA, NA, NA, NA, NA, -0.822649572649573,
NA, NA, NA, -0.925925925925926, NA, NA, NA, -0.6484375, NA, NA,
NA, 16.0277777777778, NA, NA, NA, -0.990476190476191, NA, NA,
NA, 2.5, NA, NA, NA, -0.602011494252873, NA, NA, NA, 2.53846153846154,
NA, NA, NA, -0.611111111111111, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1.6195652173913, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, -0.595238095238095, NA, NA, NA, -0.955145118733509,
NA, NA, NA, 1.13461538461538, NA, NA, NA, -0.2, NA, NA, NA, -0.897435897435897,
NA, NA, NA, -1, NA, NA, NA, -0.929577464788732, NA, NA, NA, -0.48109243697479,
NA, NA, NA, -0.161904761904762, NA, NA, NA
), `%D C8` = c(
-1,
NA, NA, NA, -0.241685144124168, NA, NA, NA, -1, NA, NA, NA, -0.963477698771816,
NA, NA, NA, -0.530487804878049, NA, NA, NA, -0.642094017094017,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -1,
NA, NA, NA, -0.55, NA, NA, NA, -0.391304347826087, NA, NA, NA,
-0.380434782608696, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, 0.403846153846154,
NA, NA, NA, -1, NA, NA, NA, 2.2051282051282, NA, NA, NA, -1,
NA, NA, NA, -1, NA, NA, NA, -0.508403361344538, NA, NA, NA, -1,
NA, NA, NA
), `%D EOT` = c(
-0.974337748344371, NA, NA, NA, NA,
NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, 0.0609756097560976,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.75,
NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.153735632183908,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, -1, NA, NA, NA, NA,
NA, NA, NA, 0.0326086956521738, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.572559366754617,
NA, NA, NA, NA, NA, NA, NA, -1, NA, NA, NA, NA, NA, NA, NA, -0.713375796178344,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, -0.904761904761905,
NA, NA, NA
), Response = c(
"PR", NA, NA, NA, "MR", NA, NA, NA,
"CR", NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA,
NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA,
"PD", NA, NA, NA, "VGPR", NA, NA, NA, "VGPR", NA, NA, NA, "MR",
NA, NA, NA, "PR", NA, NA, NA, "PR", NA, NA, NA, "PD", NA, NA,
NA, "PD", NA, NA, NA, "MR", NA, NA, NA, "PD", NA, NA, NA, "PR",
NA, NA, NA, "VGPR", NA, NA, NA, "MR", NA, NA, NA, "PR", NA, NA,
NA, "MR", NA, NA, NA, "PR", NA, NA, NA, "VGPR", NA, NA, NA
),
status = c(
"Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Nonresponder",
"Responder", "Responder", "Responder", "Responder", "Nonresponder",
"Nonresponder", "Nonresponder", "Nonresponder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder", "Responder", "Responder", "Responder",
"Responder", "Responder"
), cycle = c(
"BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT",
"BS", "C4", "C8", "EOT", "BS", "C4", "C8", "EOT", "BS", "C4",
"C8", "EOT"
), MYD88_VAF = c(
24.16, 2.4, 0, 0.62, 4.51, 3.06,
3.42, NA, 12.72, 0.15, 0, 0, 30.94, 0.37, 1.13, 0, 1.64,
NA, 0.77, 1.74, 9.36, 1.66, 3.35, NA, 0.27, 0.02, 0, 0, 1.28,
0.45, 0, NA, 0.36, 6.13, NA, 0.09, 1.05, 0.01, NA, 0, 0.06,
0.21, NA, NA, 6.96, 2.77, NA, 5.89, 0.13, 0.46, NA, NA, 0.36,
0.14, 0, 0, 0.6, NA, 0.27, 0, 0.23, NA, 0.14, NA, 0.92, 2.41,
0.57, 0.95, NA, 1.4, 0, 0, NA, 2.23, 0.13, 0.79, NA, 2.82,
0.93, 2.03, 0.42, 0.17, 0, NA, 3.79, 0.17, NA, 1.62, 0.52,
1.11, 0.73, NA, 0.4, 0.32, 0, 0, 0.78, 0.08, 2.5, NA, 1.57,
0, 0, 0.45, 1.42, 0.1, 0, NA, 4.76, 2.47, 2.34, NA, 1.05,
0.88, 0, 0.1
), change = c(
0, -21.76, -24.16, -23.54, 0, -1.45,
-1.09, NA, 0, -12.57, -12.72, -12.72, 0, -30.57, -29.81,
-30.94, 0, NA, -0.87, 0.1, 0, -7.7, -6.01, NA, 0, -0.25,
-0.27, -0.27, 0, -0.83, -1.28, NA, 0, 5.77, NA, -0.27, 0,
-1.04, NA, -1.05, 0, 0.15, NA, NA, 0, -4.19, NA, -1.07, 0,
0.33, NA, NA, 0, -0.22, -0.36, -0.36, 0, NA, -0.33, -0.6,
0, NA, -0.09, NA, 0, 1.49, -0.35, 0.0299999999999999, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, -0.25, -0.42,
NA, 0, -3.62, NA, -2.17, 0, 0.59, 0.21, NA, 0, -0.08, -0.4,
-0.4, 0, -0.7, 1.72, NA, 0, -1.57, -1.57, -1.12, 0, -1.32,
-1.42, NA, 0, -2.29, -2.42, NA, 0, -0.17, -1.05, -0.95
)
), row.names = c(
NA,
-116L
), groups = structure(list(ID = c(
1, 2, 5, 7, 13, 14, 15,
17, 18, 19, 20, 22, 23, 24, 25, 27, 29, 30, 32, 33, 34, 35, 39,
41, 42, 45, 46, 48, 52
), .rows = list(
1:4, 5:8, 9:12, 13:16,
17:20, 21:24, 25:28, 29:32, 33:36, 37:40, 41:44, 45:48, 49:52,
53:56, 57:60, 61:64, 65:68, 69:72, 73:76, 77:80, 81:84, 85:88,
89:92, 93:96, 97:100, 101:104, 105:108, 109:112, 113:116
)), row.names = c(
NA,
-29L
), class = c("tbl_df", "tbl", "data.frame"), .drop = TRUE), class = c(
"grouped_df",
"tbl_df", "tbl", "data.frame"
))
delta |>
drop_na(change) |>
ggplot(aes(x = cycle, y = change, color = ID, group = ID))
geom_hline(yintercept = 20, col = "black", lty = 2)
geom_hline(yintercept = -30, col = "black", lty = 2)
geom_point(aes(size = 1), na.rm = TRUE)
geom_line()
labs(
y = "% Change from Baseline", x = "Cycle",
title = "4. Spider Plot for MYD88 VAF"
)
facet_wrap(~status)
scale_color_brewer(palette = "Paired")
theme(
legend.title = element_text(color = "black", size = 8, face = "bold"),
legend.text = element_text(color = "blue", size = 7),
legend.position = "none"
)
Created on 2022-07-18 by the reprex package (v2.0.1)