0

I want to plot a split-violin plot as described here for each column of df (second column onwards). The x-axis would be subtype, and the fill is pathologic_stage.

My code returned "data must be a <data.frame>, or an object coercible by fortify(), not a character vector." error.

devtools::install_github("psyteachr/introdataviz")
library(introdataviz)

Plot:

for (i in 1:nrow(df[,-c(1:2)])){
  print(ggplot(df[,i], aes(x=df$pathologic_stage, y=df[,i], fill=df$subtype)) + 
    geom_split_violin(alpha = .4, trim = FALSE) +
    geom_boxplot(width = .2, alpha = .6, fatten = NULL, show.legend = FALSE) +
    stat_summary(fun.data = "mean_se", geom = "pointrange", show.legend = F, position = position_dodge(.175)) +
    scale_x_discrete(name = "Stage", labels = c("stage i", "stage ii", "stage iii", "stage iv")) +
    scale_y_continuous(name = "Gene Expression", breaks = seq(200, 800, 100), limits = c(200, 800)) +
    scale_fill_brewer(palette = "Dark2", name = "Subtype") +
    theme_minimal())
}

Traceback:

Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`, not a
  character vector.
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error in `fortify()`:
! `data` must be a <data.frame>, or an object coercible by `fortify()`, not a
  character vector.
---
Backtrace:
 1. base::print(...)
 3. ggplot2:::ggplot.default(...)
 5. ggplot2:::fortify.default(data, ...)
Run `rlang::last_trace()` to see the full context.

Data:

dput(df[1:50,1:50])

> dput(df[1:50,1:50])
structure(list(pathologic_stage = c("stage i", "stage i", "stage i", 
"stage i", "stage i", "stage iii", "stage i", "stage i", "stage i", 
"stage i", "stage i", "stage iii", "stage i", "stage i", "stage i", 
"stage i", "stage i", "stage i", "stage ii", "stage i", "stage i", 
"stage i", "stage i", "stage i", "stage i", "stage iii", "stage ii", 
"stage ii", "stage ii", "stage i", "stage i", "stage ii", "stage iv", 
"stage iv", "stage i", "stage iii", "stage iv", "stage iv", "stage iii", 
"stage iv", "stage i", "stage i", "stage i", "stage iii", "stage i", 
"stage iii", "stage i", "stage i", "stage ii", "stage i"), subtype = c("KIRP", 
"KIRP", "KIRP", "KIRP", "KIRP", "KIRP", "KIRC", "KIRC", "KIRC", 
"KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRP", 
"KIRP", "KIRP", "KIRP", "KIRP", "KIRP", "KIRP", "KIRP", "KIRP", 
"KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRP", "KIRC", 
"KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRC", 
"KIRC", "KIRC", "KIRC", "KIRC", "KIRC", "KIRP", "KIRC", "KIRP", 
"KIRC"), A1BG = c(66.4361, 39.6938, 77.9754, 53.1898, 191.8009, 
50.8509, 12.4224, 28.5205, 80.5208, 19.1515, 53.2646, 21.3555, 
33.4962, 42.2477, 16.9054, 58.6972, 35.6614, 109.9437, 14.429, 
70.2027, 59.4344, 22.4731, 28.4957, 19.4994, 25.8724, 298.569, 
148.3682, 139.7575, 61.7103, 220.857, 13.2709, 7.5077, 106.505, 
129.3458, 28.7289, 80.3571, 18.543, 40.3925, 72.5155, 54.2779, 
7.6608, 45.0186, 15.8792, 29.0844, 24.1362, 24.808, 127.0924, 
51.6359, 16.2703, 40.4216), A1CF = c(0.374, 0.6125, 1.1703, 23.663, 
2.9283, 47.0016, 126.8116, 316.5775, 315.9734, 190.5771, 127.0227, 
335.9949, 59.898, 466.994, 595.8235, 136.7737, 0, 0, 0.7762, 
86.9447, 0.9457, 12.178, 8.3199, 41.1204, 72.8039, 1.4406, 224.4191, 
88.0664, 9.8863, 38.624, 5.9625, 271.4374, 5.5, 0, 106.4724, 
73.3766, 168.3626, 6.6141, 141.568, 50.2988, 247.236, 36.9128, 
173.1216, 42.394, 51.7409, 571.1754, 3.9402, 276.699, 0.6258, 
171.743), A2BP1 = c(0, 1.2249, 2.3406, 0.4733, 5.8565, 1.6207, 
0, 0, 0.3495, 0, 0, 0, 0.4248, 0.5456, 0, 0, 0.8703, 2.0471, 
0.7762, 1.2938, 0, 0.4684, 0, 0, 3.6101, 1.9208, 0, 0, 0, 2.414, 
2.1295, 1.2338, 1, 23.2415, 0, 0.6494, 1.8501, 0.7781, 0.564, 
0.498, 0, 0.3729, 0, 0.3563, 0.9582, 0, 26.2683, 0, 0, 0), A2LD1 = c(53.1638, 
150.1945, 175.7929, 133.7056, 90.0146, 220.5429, 189.9586, 1274.5478, 
79.3569, 61.2079, 69.818, 62.3596, 247.3534, 73.4943, 211.3834, 
118.192, 141.7798, 85.4555, 70.9227, 61.1951, 121.9658, 75.5082, 
121.9032, 51.8594, 67.5331, 80.4898, 87.5234, 143.2993, 183.569, 
147.924, 93.6542, 67.6619, 43.075, 37.83, 66.9431, 128.0065, 
53.3858, 115.3026, 161.2126, 66.1355, 661.2867, 38.8255, 58.9311, 
59.1628, 91.8562, 2430.7561, 50.8291, 142.4078, 74.3054, 187.11
), A2ML1 = c(0.374, 10.4119, 0, 0.4733, 0, 0.4052, 0, 1.426, 
0, 0.3236, 0, 0, 0.8496, 0.5456, 0, 2.887, 0, 0, 0, 0.2588, 0, 
0.9368, 0.416, 0, 1.2034, 0, 0, 0, 4.9432, 0.6035, 0, 0, 0, 0.447, 
0, 1.9481, 0.9251, 1.9453, 1.128, 3.4861, 0, 0.3729, 0, 0.3563, 
0, 2.3627, 0, 0, 4.3805, 0), A2M = c(29835.2992, 9396.2578, 10393.2768, 
7446.9238, 22716.3543, 4080.9887, 14629.3271, 22602.4385, 27446.5851, 
37196.4554, 53143.7176, 43071.7036, 42157.158, 36148.0142, 27739.0492, 
19953.5583, 2267.7372, 48050.0768, 15309.9757, 11263.9665, 3457.7381, 
6895.8267, 2168.5237, 6824.1776, 2439.627, 29292.8595, 33466.0932, 
13926.7709, 10773.4355, 11296.4092, 13068.9566, 3865.4719, 19986.845, 
7094.0991, 54466.2931, 44946.9091, 46699.9352, 7469.8126, 21914.4162, 
26395.3586, 53265.4096, 41444.7614, 43623.3424, 38610.7374, 30405.7241, 
19550.9096, 4950.5106, 57936.7379, 6543.7985, 66622.8908), A4GALT = c(1418.1002, 
915.6331, 2365.7109, 2372.9295, 3014.6413, 802.269, 1449.2754, 
1129.8871, 994.058, 1440.1676, 1554.2071, 1281.1242, 1143.5854, 
1046.0993, 1333.0483, 1711.6564, 1312.8808, 2354.1453, 1895.4109, 
1403.0185, 3031.7681, 1605.6206, 866.9336, 1641.2396, 2241.8773, 
1029.0516, 1906.7916, 1368.2195, 1059.8122, 1135.7876, 365.4174, 
1640.3455, 1205.5, 347.282, 1556.7386, 1881.8182, 1510.1758, 
1173.413, 1451.7766, 863.5458, 1630.3648, 1073.8255, 1345.0813, 
1833.274, 957.8463, 310.1004, 1830.2413, 1349.0291, 179.5995, 
1475.9358), A4GNT = c(22.8123, 0, 2.3406, 5.6791, 5.8565, 4.8622, 
27.9503, 32.7986, 45.4387, 28.7969, 33.1715, 25.5509, 10.1954, 
20.4583, 17.3901, 67.4847, 2.611, 5.6295, 13.1949, 25.3589, 1.4185, 
8.8993, 32.8636, 5.3635, 120.3369, 8.6435, 5.1354, 5.1053, 2.4716, 
4.828, 0, 99.3214, 17, 0, 0, 6.4935, 42.0907, 15.5625, 44.5572, 
27.3904, 11.8395, 2.2371, 0, 6.7688, 10.8592, 8.2693, 10.5073, 
1.9417, 0, 8.0601), AAA1 = c(0.7479, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0.8496, 0, 0, 0, 0, 0, 0, 0, 0.4728, 0, 0, 0, 0, 0.4802, 
0, 0, 0, 0, 0.4259, 0, 1, 0.447, 0, 0, 0.4625, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0), AAAS = c(624.1586, 746.5932, 1053.8327, 
953.1472, 1301.6105, 1170.1783, 695.1346, 648.8414, 479.2031, 
540.0224, 643.2039, 785.436, 622.3449, 581.2875, 607.2269, 850.5955, 
1018.7119, 577.7892, 568.1576, 755.0734, 760.3062, 1000, 785.3986, 
1072.1097, 1236.4621, 964.7059, 543.8439, 516.2731, 516.0652, 
739.2879, 838.586, 1070.9439, 1093.5, 838.0356, 620.9022, 847.4026, 
832.5624, 1299.4693, 1143.26, 890.9363, 554.714, 471.6629, 581.7196, 
978.9811, 638.7771, 578.2634, 2372.0243, 498.5437, 754.6934, 
487.9485), AACSL = c(0.374, 61.2464, 22.8204, 35.9678, 21.9619, 
21.4749, 70.911, 84.1355, 67.1094, 37.2095, 23.0583, 21.7183, 
8.921, 74.1953, 3.7061, 42.223, 15.6658, 1.5353, 33.7635, 24.0651, 
1.4185, 53.8642, 24.5437, 48.8677, 80.0241, 3.3613, 49.3003, 
2.5526, 18.784, 72.42, 3.4072, 42.5663, 43.5, 0, 8.2189, 16.8831, 
40.7031, 7.3922, 25.9447, 32.8685, 82.8763, 100.6711, 17.8156, 
46.669, 23.9541, 27.1707, 21.6713, 151.4563, 153.9424, 37.5107
), AACS = c(593.8669, 1303.3226, 813.9263, 739.7066, 740.8492, 
1232.577, 271.7391, 391.6815, 510.3111, 603.7638, 473.301, 425.9342, 
392.9482, 596.563, 556.4821, 852.7607, 1024.369, 663.7666, 881.3428, 
798.8045, 708.768, 894.6136, 832.406, 1222.8844, 806.8592, 411.5246, 
809.3465, 583.9183, 905.5858, 339.7707, 896.0818, 825.4164, 955, 
586.178, 680.3026, 611.039, 567.5301, 1069.9223, 329.9492, 429.2829, 
543.571, 424.3102, 319.907, 522.2658, 592.4658, 519.1967, 591.036, 
640.7767, 546.9337, 390.2968), AADACL2 = c(0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0.6035, 0, 0, 2, 0, 0.3736, 0, 0, 0, 0, 1.494, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0), AADACL3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0.4248, 0, 0, 0, 0, 0, 1.5523, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 3.5, 0, 0, 0, 0.4625, 0, 1.128, 0, 0, 0, 0, 
0, 0.3194, 0, 0, 0, 0, 0), AADACL4 = c(0, 0, 1.1703, 0, 0, 0, 
0, 0, 0, 0, 0, 0.2555, 0, 0, 0, 0, 0, 0, 105.1712, 0, 0, 0, 0, 
0, 0, 0.9604, 0, 0, 0.4943, 1.8105, 0, 0, 0, 0.2235, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4854, 0, 0), AADAC = c(0, 0, 
0, 0, 0, 0, 0, 0.9507, 0, 0, 0, 38.3264, 0.4248, 0.2728, 1.9956, 
0.3609, 0, 0, 11.6426, 0, 0, 0, 0, 0, 0.6017, 0.4802, 0, 1.2763, 
0, 0, 2.1295, 0, 0.5, 0.2235, 2.6151, 257.7922, 0.4625, 0, 1.128, 
3.9841, 0.3482, 0.7457, 0, 0.7125, 0, 0, 0.6567, 0, 0, 0), AADAT = c(68.0628, 
124.3301, 70.8016, 45.433, 20.4978, 185.1702, 172.8778, 107.9026, 
70.9542, 96.421, 63.9159, 99.9042, 162.7018, 66.8303, 104.3404, 
77.2284, 100.9574, 34.8004, 10.0902, 39.8497, 188.6581, 68.3841, 
127.2945, 85.8164, 106.4982, 81.1525, 22.0824, 35.0989, 104.7949, 
65.178, 72.8279, 123.3806, 86.5, 126.9345, 61.6419, 107.7922, 
149.3987, 49.411, 93.0626, 57.7689, 129.886, 122.2968, 80.945, 
123.6195, 73.7788, 42.5281, 169.4303, 73.7864, 723.4043, 48.3608
), AAGAB = c(674.6447, 1476.0374, 985.9567, 1247.0421, 1244.5095, 
826.5802, 702.381, 451.0992, 634.7431, 499.2538, 447.411, 531.4596, 
856.4146, 494.2717, 666.8092, 576.6871, 1191.0357, 592.6305, 
939.9437, 1205.064, 1584.444, 1091.3349, 1051.2194, 962.4553, 
783.3935, 513.8055, 669.1488, 752.3931, 1244.1918, 553.4098, 
2583.4753, 858.7292, 808, 1601.8772, 549.547, 498.0519, 508.7882, 
542.7424, 393.683, 690.239, 510.1419, 413.1245, 472.8892, 722.1233, 
1029.0699, 716.4796, 663.2737, 501.4563, 1657.0713, 434.0076), 
    AAK1 = c(732.2364, 1728.9848, 1579.2861, 1894.4628, 1161.0542, 
    2443.6791, 1035.1967, 1074.7475, 1162.5306, 1274.5046, 814.3204, 
    887.8952, 881.4783, 1433.1697, 1143.7531, 1019.4875, 1471.2794, 
    1201.6377, 1818.958, 1536.0232, 1534.3243, 1779.8595, 1978.0563, 
    1733.0155, 1841.1552, 1137.0948, 728.72, 565.4116, 1789.4217, 
    310.1992, 1095.8262, 1837.1376, 828, 1489.4687, 752.405, 
    947.4026, 827.012, 1209.9849, 956.5708, 1176.2948, 905.7195, 
    955.6301, 824.1673, 984.6812, 1169.6009, 1481.9846, 1195.206, 
    1325.7282, 1187.7347, 770.9835), AAMP = c(2327.5991, 3045.1692, 
    2152.7209, 2275.4378, 1932.6501, 3489.8703, 2151.1387, 1601.9014, 
    1656.0643, 1712.6055, 1910.5987, 2684.382, 1446.8989, 1904.5281, 
    1981.8972, 2886.6835, 1613.577, 1887.9222, 3891.336, 1933.4847, 
    2602.9138, 1873.0679, 1818.3142, 2419.5471, 1957.2804, 1505.4022, 
    3482.8604, 2273.1334, 1731.0924, 2270.9716, 1430.5792, 1304.7502, 
    3140.5, 1152.0197, 2074.1571, 1589.6104, 2739.1304, 2360.8323, 
    1771.0096, 2385.9562, 2149.5604, 1339.299, 2126.646, 3134.3071, 
    2141.5003, 2288.8364, 1322.6071, 1639.8058, 2118.8986, 2173.448
    ), AANAT = c(2.6178, 1.8374, 1.1703, 1.4198, 1.4641, 2.4311, 
    0, 0, 0, 0.6471, 0, 0.511, 0, 0.2728, 0, 2.1653, 0.8703, 
    2.0471, 0, 0.5175, 0.9457, 0.4684, 1.248, 1.1919, 0.6017, 
    2.401, 0.5135, 1.9145, 0.4943, 1.8105, 1.2777, 0.6169, 1.5, 
    1.3409, 0.3736, 0, 0.9251, 1.1672, 2.2561, 1.494, 0.3482, 
    0, 0, 0, 0.6388, 1.772, 1.3134, 0, 0.6258, 0.62), AARS2 = c(525.718, 
    641.2249, 668.8122, 645.9063, 680.8199, 584.2747, 262.412, 
    502.4219, 523.2366, 524.7859, 475.2063, 464.9505, 246.8097, 
    561.6312, 422.7582, 626.817, 455.544, 327.5128, 570.4589, 
    599.0258, 477.0827, 659.9485, 618.9923, 541.1144, 422.3827, 
    400.9604, 409.2952, 205.4882, 560.0445, 232.3476, 497.0017, 
    478.6798, 623.49, 387.0049, 305.2059, 779.6818, 662.8076, 
    341.1963, 681.6977, 750.9861, 588.46, 527.9605, 612.6995, 
    425.7214, 452.5736, 596.5682, 743.3328, 487.3544, 555.6946, 
    417.878), AARSD1 = c(597.9806, 989.7412, 1583.9672, 924.7515, 
    2733.5286, 754.8622, 638.1988, 520.4991, 611.3247, 399.5972, 
    499.1909, 679.9106, 383.1776, 468.6307, 386.8577, 765.7885, 
    787.6414, 442.6817, 580.1882, 414.7987, 620.3493, 666.5105, 
    697.2076, 641.8355, 707.5812, 652.1008, 690.7177, 636.8858, 
    348.4923, 601.6898, 353.9182, 562.6157, 708, 286.273, 586.1586, 
    728.5714, 735.4302, 1082.3723, 866.8923, 628.9841, 413.3368, 
    590.9769, 653.3695, 804.0613, 838.0756, 341.4058, 1069.1184, 
    433.0097, 473.0914, 541.5795), AARS = c(1833.2087, 3809.5238, 
    4739.0287, 3400.8519, 3606.1493, 2477.7147, 1309.5238, 1984.0761, 
    2380.6361, 2323.8112, 2363.2686, 2918.4286, 2183.9422, 2660.3928, 
    2749.3407, 2912.306, 4083.1158, 2761.5148, 2589.6963, 3280.8689, 
    3703.6555, 3992.5059, 3298.0084, 3389.7497, 1912.7557, 1920.2881, 
    2473.2315, 1499.6809, 2709.8369, 1821.3639, 3267.4617, 2870.4503, 
    3894, 3654.9528, 3225.927, 2321.4286, 2848.7512, 7012.0765, 
    1807.1066, 2709.6614, 3043.7886, 2310.2163, 2445.0039, 4618.0976, 
    4203.7923, 2442.4099, 1290.4285, 2641.2621, 2016.2703, 3129.8148
    ), AASDHPPT = c(790.5123, 1154.494, 666.2493, 776.1477, 342.6061, 
    1030.7942, 1660.4555, 907.9026, 1339.0423, 1158.67, 984.2233, 
    1213.9253, 1235.7689, 1284.2335, 1423.7047, 755.9906, 1221.497, 
    786.5916, 1135.9115, 981.7507, 855.3444, 943.2881, 1168.53, 
    1003.5757, 625.1504, 609.3637, 1113.8785, 1341.4167, 1309.9357, 
    1214.2426, 661.8399, 617.52, 948.5, 997.5798, 1234.2991, 
    797.4026, 1054.0703, 504.2252, 668.3587, 882.4701, 964.2204, 
    1136.4653, 1102.6336, 1217.638, 1085.2823, 1321.9138, 406.5014, 
    983.4951, 833.5419, 1053.7084), AASDH = c(214.2857, 250.4976, 
    148.6249, 229.0582, 121.5227, 257.2934, 277.9503, 295.1872, 
    262.1461, 329.061, 267.3948, 253.4653, 361.9371, 288.3252, 
    283.0874, 209.3107, 219.7563, 219.0379, 387.6977, 214.5154, 
    322.4682, 212.6464, 203.8376, 199.6424, 116.1252, 106.6026, 
    238.7983, 96.3625, 247.1577, 153.2891, 362.862, 140.037, 
    220.5, 347.0585, 223.4052, 157.7922, 192.4144, 62.25, 159.0525, 
    171.8127, 301.9065, 266.2192, 260.2634, 161.7385, 187.4811, 
    193.1483, 289.6076, 233.4951, 317.2716, 226.924), AASS = c(427.0755, 
    305.0069, 473.3762, 1046.8528, 266.4714, 1009.7245, 414.0787, 
    675.4605, 589.654, 367.5647, 453.8835, 310.1884, 880.2039, 
    700.7638, 1040.5531, 228.0765, 1614.4473, 283.0092, 468.8076, 
    392.545, 515.3817, 684.3091, 888.5653, 816.4482, 2000, 418.2473, 
    209.0127, 58.7109, 551.656, 441.7622, 566.4395, 2349.1672, 
    294, 223.6996, 238.7223, 533.1169, 534.2276, 253.6689, 1132.5437, 
    457.1713, 328.7194, 469.0529, 416.7312, 217.6701, 276.9099, 
    142.9415, 2046.2978, 207.2816, 451.8148, 400.527), AATF = c(1334.3306, 
    1346.1951, 1459.9181, 1310.9323, 1692.5329, 1314.4246, 1440.9938, 
    1126.5597, 1240.1258, 913.7347, 1110.0324, 1635.2603, 745.5395, 
    1126.2957, 844.4159, 1340.6712, 860.3133, 1223.132, 2095.6631, 
    941.901, 1384.4381, 1051.5222, 1034.1636, 1017.2825, 836.3418, 
    1105.8824, 1010.6561, 570.5169, 847.7509, 656.6083, 551.9591, 
    1179.5188, 1446.5, 964.7466, 1332.5862, 991.5584, 1271.5079, 
    3250.2295, 1002.2561, 1498.008, 1168.6254, 1619.3139, 1367.1572, 
    1391.8774, 1324.185, 1135.8535, 1058.6111, 1287.3786, 1419.8999, 
    1453.6154), AATK = c(127.5243, 14.6991, 12.873, 8.992, 5.8712, 
    15.3971, 54.3478, 95.0683, 86.3334, 95.7739, 337.3786, 106.8029, 
    120.2209, 161.0038, 91.5117, 153.8217, 3.4813, 117.1955, 
    17.4639, 6.2103, 18.9131, 7.4941, 9.5679, 25.0298, 8.4236, 
    80.1921, 58.0306, 40.2042, 15.8181, 132.1666, 35.3492, 30.8452, 
    41, 53.1873, 74.7175, 281.3182, 181.3136, 41.6297, 283.1359, 
    118.0279, 46.6614, 77.9269, 206.8164, 134.7667, 37.3685, 
    46.6627, 9.8506, 145.6311, 43.8048, 162.7528), ABAT = c(142.1092, 
    846.4247, 1145.1141, 1233.7908, 563.6896, 5905.1864, 1161.4907, 
    360.7843, 339.0423, 480.1637, 239.0777, 633.1523, 234.4945, 
    718.767, 3055.2348, 166.3659, 2442.9939, 83.4186, 34.9277, 
    2107.8917, 1005.7035, 1555.0351, 3974.8323, 1581.6448, 2007.2202, 
    258.8235, 232.1222, 709.6362, 2171.5274, 642.7278, 809.6252, 
    3375.694, 207.5, 254.0924, 104.6045, 562.987, 391.7669, 263.0064, 
    881.5567, 639.4422, 703.0556, 144.6682, 386.9094, 1405.415, 
    836.798, 346.1311, 193.7285, 328.6408, 4592.6158, 233.1241
    ), ABCA10 = c(23.2199, 9.7994, 7.0217, 19.4037, 7.3206, 17.0178, 
    23.8095, 48.4848, 19.5841, 23.2964, 19.0129, 34.5193, 22.5149, 
    35.7774, 11.9735, 24.908, 10.4439, 7.6766, 22.8971, 8.798, 
    23.6414, 3.7471, 8.7359, 7.7473, 9.627, 31.6927, 3.0813, 
    0, 1.9773, 65.7815, 52.385, 8.6366, 20, 12.7381, 5.6038, 
    44.1558, 68.4551, 5.4469, 154.5685, 24.4024, 7.3126, 50.3356, 
    8.1332, 3.2063, 3.5133, 1.1813, 105.0731, 7.2816, 692.8661, 
    3.1001), ABCA11P = c(58.1862, 93.9335, 27.7882, 59.1671, 
    38.6091, 48.9425, 65.9834, 80.1806, 87.3471, 70.9439, 118.1594, 
    57.7962, 116.7842, 90.6137, 58.6558, 56.6402, 24.2776, 45.5937, 
    83.2871, 46.6319, 82.6928, 34.8197, 51.2215, 51.9249, 68.1528, 
    69.2341, 36.0149, 28.6918, 36.871, 113.8443, 83.7095, 47.3288, 
    81.95, 62.2493, 35.7037, 119.5779, 104.7086, 51.7842, 93.5759, 
    133.2769, 35.0205, 100.3691, 73.993, 29.1557, 61.6516, 38.4406, 
    217.0087, 58.5, 347.7597, 76.5558), ABCA12 = c(11.5931, 124.3301, 
    89.526, 141.0317, 178.6237, 1205.0243, 120.6004, 220.0832, 
    99.266, 252.7007, 67.9612, 665.602, 160.1529, 25.9138, 95.2177, 
    123.0603, 57.8764, 22.5179, 553.0222, 752.7445, 42.5544, 
    530.2108, 396.8592, 471.9905, 11.432, 85.9544, 6.6761, 15.3159, 
    665.3485, 255.8841, 4.2589, 14.1888, 38, 2.0113, 98.6271, 
    84.4156, 413.9685, 66.1407, 73.3221, 33.8645, 104.4659, 83.5198, 
    266.8474, 352.3335, 248.8037, 1377.4365, 6.5671, 80.5825, 
    51.3141, 66.0312), ABCA13 = c(25.4301, 1.2249, 12.873, 0, 
    5.8565, 0, 2.0704, 0, 0.3495, 0.9707, 0, 1.022, 4.6729, 0.5456, 
    3.9912, 4.6914, 6.0923, 28.6592, 541.3796, 112.3036, 4.2554, 
    14.0515, 22.8797, 4.7676, 361.0108, 0.4802, 0.5135, 0, 17.301, 
    1.8105, 16.6099, 22.2085, 10.5, 9.386, 0.7472, 1.2987, 4.1628, 
    0, 2.2561, 25.3984, 1.0447, 0, 1.5492, 0.7125, 69.6267, 1.772, 
    11.8207, 1.9417, 41.9274, 0.31), ABCA17P = c(36.2752, 12.8617, 
    8.7771, 4.7326, 1.4641, 29.5786, 36.2319, 13.7849, 17.8259, 
    10.0304, 4.4498, 26.8285, 12.3195, 4.0917, 2.5657, 39.336, 
    8.2681, 9.7236, 102.4546, 17.0784, 8.9837, 3.7471, 3.328, 
    4.1716, 5.4152, 13.4454, 4.6219, 16.5922, 4.4488, 89.318, 
    19.1652, 1.2338, 42.5, 23.2415, 5.9774, 42.8571, 37.9278, 
    12.45, 671.1788, 46.3147, 20.1967, 18.6428, 4.6476, 8.9063, 
    6.3878, 25.3987, 19.0445, 23.7864, 1.2516, 12.0902), ABCA1 = c(378.7509, 
    1455.1891, 1033.3528, 1713.6346, 856.5154, 2420.0324, 900.0776, 
    6174.8782, 2993.3555, 5553.7859, 1983.3738, 3218.343, 1494.0357, 
    3179.1135, 3256.4806, 2258.1992, 1283.2768, 461.1054, 877.0505, 
    2667.3136, 670.9276, 1710.5012, 1582.4284, 1420.7211, 1433.8147, 
    1946.1945, 1939.1295, 1381.6209, 3498.7296, 1465.9022, 2007.5128, 
    917.9272, 1577.985, 3137.639, 3958.8568, 3062.8312, 1044.3663, 
    1159.399, 2689.1371, 1853.0378, 2365.77, 3466.0291, 1497.2657, 
    913.0638, 2721.4748, 2339.622, 486.6196, 2814.034, 498.1227, 
    1388.4926), ABCA2 = c(4267.3897, 1250.0383, 1385.6056, 1640.7951, 
    1060.0293, 1760.5348, 942.029, 2243.1373, 2808.8081, 1837.1763, 
    2047.7346, 1324.0498, 954.9703, 1930.9875, 1299.4085, 3079.0328, 
    1367.7111, 1968.782, 1856.6023, 2517.5151, 3804.8406, 1973.7705, 
    2435.6508, 1859.9523, 1364.0193, 1726.2905, 1586.8533, 479.8979, 
    1128.0277, 1065.178, 1576.661, 907.4645, 1307.5, 1616.4032, 
    1230.9704, 1818.1818, 1482.4237, 433.4158, 1600.6768, 1769.9203, 
    1440.585, 2171.8867, 1596.4369, 868.5429, 1585.4448, 746.013, 
    2508.6193, 3495.1456, 458.6984, 1278.4624), ABCA3 = c(1893.4181, 
    1465.013, 3856.0562, 3091.3393, 3431.918, 2689.222, 3052.795, 
    2074.391, 2635.7917, 1536.5886, 1269.0129, 2005.2379, 823.7043, 
    1402.0731, 1331.3378, 2961.7467, 3307.6588, 924.7697, 1757.6404, 
    2490.8624, 1433.1393, 4549.4145, 3365.3996, 2532.1812, 1309.2659, 
    1638.8956, 1541.1478, 1419.2725, 1534.8492, 1106.2161, 882.0273, 
    1491.0549, 2005, 446.2819, 1206.6872, 1635.0649, 1496.7623, 
    2689.9793, 1532.4309, 2035.8566, 1663.4456, 1413.8702, 570.1007, 
    1497.6844, 2466.3185, 3694.0343, 1451.3216, 2634.9515, 56.9462, 
    1292.4126), ABCA4 = c(881.825, 3.0623, 0.5851, 0.9465, 1.4641, 
    2.0259, 3.6232, 6.1794, 4.1943, 5.5005, 11.3269, 6.8988, 
    22.5149, 3.8189, 5.9867, 2.887, 0, 263.5619, 580.9644, 2.0701, 
    1.4185, 0.4684, 1.248, 0, 3.0084, 7.2029, 1.5406, 0.6382, 
    3.4602, 4.828, 9.7956, 1.2338, 2.5, 22.7946, 5.6038, 26.6234, 
    3.7003, 106.9922, 6.7682, 12.9482, 4.5269, 4.1014, 7.7459, 
    2.85, 4.1521, 0.5907, 0.6567, 9.2233, 41.3016, 7.7501), ABCA5 = c(730.7068, 
    355.2289, 297.835, 539.044, 169.8389, 378.0389, 890.2692, 
    849.4355, 726.6585, 900.4688, 439.7249, 792.3092, 627.0178, 
    741.3639, 399.9715, 631.1729, 644.0383, 318.3214, 267.003, 
    248.931, 560.3002, 385.4801, 394.3633, 402.2646, 486.7629, 
    650.6603, 523.3021, 232.291, 467.6223, 947.4955, 1552.8109, 
    475.0154, 348.5, 857.925, 399.7385, 816.8831, 1063.3673, 
    122.5547, 1443.2882, 478.5857, 454.4267, 679.3438, 608.4431, 
    327.0395, 310.4457, 282.9297, 1832.2115, 695.6311, 646.3079, 
    379.4466), ABCA6 = c(10.0972, 20.8238, 32.1826, 26.0293, 
    2.9283, 5.2674, 8.7992, 62.7451, 15.0297, 26.532, 47.7346, 
    17.3746, 44.6049, 56.192, 28.7934, 32.4792, 50.0435, 6.653, 
    219.6565, 98.5891, 7.0924, 11.2412, 18.7198, 36.3528, 4.2118, 
    32.1729, 3.5948, 40.2042, 7.4147, 32.589, 43.4412, 5.5521, 
    47, 4.0226, 66.4986, 38.3117, 18.5014, 11.2828, 43.9932, 
    32.3705, 44.2239, 76.4355, 23.6251, 6.4125, 439.4787, 552.2741, 
    42.0292, 213.1068, 20.6508, 8.0601), ABCA7 = c(142.8571, 
    464.2474, 815.6817, 783.7198, 1194.7291, 406.8071, 93.6853, 
    182.5312, 189.4443, 262.084, 198.6246, 196.4867, 104.9278, 
    390.3437, 84.6697, 328.4013, 358.5727, 345.957, 497.1379, 
    375.4666, 387.2455, 699.2974, 670.168, 538.1406, 419.3742, 
    1285.9544, 160.226, 49.1385, 498.2699, 106.8196, 255.5366, 
    302.8994, 183.5, 402.4806, 134.865, 348.0519, 221.0916, 723.6566, 
    329.9492, 839.1434, 90.8853, 133.1096, 60.031, 87.2818, 304.3773, 
    69.1081, 919.3893, 129.6117, 234.6683, 86.1815), ABCA8 = c(80.0299, 
    358.2912, 31.0123, 701.3725, 125.9151, 3.6467, 6.2112, 119.3108, 
    1.3981, 62.4472, 100.3236, 49.0578, 136.3636, 178.6688, 118.0244, 
    69.6499, 29.5909, 23.0297, 194.431, 147.7543, 49.174, 44.9649, 
    1329.1041, 1386.77, 359.8075, 36.9748, 13.3522, 33.8226, 
    879.387, 80.2655, 121.8058, 77.1129, 42, 17.8781, 206.2202, 
    5.8442, 149.8612, 16.7297, 75.0141, 14.4422, 167.4937, 105.1454, 
    263.749, 42.394, 83.6798, 2.3627, 283.6973, 59.2233, 150.8135, 
    142.9125), ABCA9 = c(8.2274, 11.6368, 17.5541, 8.992, 2.9283, 
    11.3452, 35.7143, 50.3862, 30.7585, 21.6786, 45.712, 28.106, 
    64.1461, 60.0109, 41.6221, 32.8401, 7.3977, 4.0942, 58.989, 
    15.5258, 15.6033, 3.2787, 1.664, 8.3433, 4.2118, 45.1381, 
    1.0271, 19.783, 0, 21.726, 52.385, 0, 51.5, 2.0113, 32.5021, 
    104.5455, 51.3414, 14.3953, 137.6199, 49.8008, 21.9378, 87.994, 
    13.9427, 8.5501, 63.2389, 2.3627, 51.2231, 12.6214, 15.0188, 
    3.1001), ABCB10 = c(429.6933, 408.5132, 263.3119, 309.0393, 
    207.9063, 521.8801, 893.3747, 526.6786, 503.3205, 626.0895, 
    475.3236, 646.4388, 565.4206, 413.257, 858.9552, 415.0126, 
    525.2393, 384.3398, 446.6867, 449.4731, 384.4085, 529.7424, 
    388.9553, 386.174, 250.3008, 412.485, 457.0548, 532.8653, 
    458.2304, 828.0024, 251.2777, 212.8316, 434.5, 269.7357, 
    502.1014, 401.9481, 508.7882, 380.8924, 271.8556, 371.0159, 
    690.5197, 423.5645, 488.3811, 440.684, 412.0112, 805.0797, 
    262.6826, 549.5146, 409.2616, 505.3088), ABCB11 = c(0, 0.6125, 
    0, 0, 0, 0, 0, 0, 0, 0.6471, 0, 2.8106, 0.4248, 0.8183, 0.2851, 
    0, 0, 0.5118, 6.9855, 0.5175, 0, 0.4684, 0, 0.5959, 0, 0, 
    0.5135, 0, 0.4943, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.564, 0, 0, 
    0.3729, 0, 0, 0, 0, 0, 0.9709, 0, 0), ABCB1 = c(83.3957, 
    410.9631, 1382.0948, 3798.8642, 2136.164, 6457.4554, 1570.911, 
    634.1058, 871.7232, 947.385, 383.8997, 779.0482, 852.1665, 
    1000, 2371.8908, 1003.2479, 426.4578, 100.8188, 3182.6914, 
    1995.8468, 107.8046, 8507.26, 3411.1591, 2440.4052, 5239.4705, 
    354.8619, 1671.0746, 183.1525, 1926.8413, 654.1943, 399.4889, 
    4606.4158, 796.5, 73.7471, 738.5822, 312.987, 518.0389, 5323.9336, 
    403.8353, 109.5618, 967.3544, 470.5444, 341.5957, 432.8465, 
    2066.1246, 2427.6432, 3770.1527, 1274.7573, 84.4806, 75.3313
    ), ABCB4 = c(14.5849, 39.8101, 25.7461, 62.4704, 177.1596, 
    97.6499, 219.9793, 21.8657, 14.3307, 49.8283, 25.89, 47.7803, 
    29.7366, 29.7327, 39.6265, 137.4955, 17.4064, 29.1709, 16.6877, 
    152.1532, 1.4185, 76.815, 233.3732, 392.1335, 320.0963, 91.2365, 
    97.5735, 17.2304, 42.0168, 12.6735, 9.7956, 133.868, 208, 
    6.4808, 41.4682, 195.4545, 6.013, 272.7329, 175.4089, 36.3546, 
    16.0181, 18.6428, 35.6313, 18.8814, 105.3982, 515.6527, 199.6388, 
    516.9903, 2.5031, 288.9251)), row.names = c("TCGA-2Z-A9J9-01A", 
"TCGA-2Z-A9JO-01A", "TCGA-2Z-A9JP-01A", "TCGA-2Z-A9JR-01A", "TCGA-2Z-A9JT-01A", 
"TCGA-5P-A9JU-01A", "TCGA-A3-3306-01A", "TCGA-A3-3322-01A", "TCGA-A3-3324-01A", 
"TCGA-A3-3331-01A", "TCGA-A3-3349-01A", "TCGA-A3-3352-01A", "TCGA-A3-3365-01A", 
"TCGA-A3-3370-01A", "TCGA-A3-3373-01A", "TCGA-A3-A6NI-01A", "TCGA-A4-7584-01A", 
"TCGA-A4-7828-01A", "TCGA-A4-7915-01A", "TCGA-A4-7997-01A", "TCGA-A4-8312-01A", 
"TCGA-A4-8517-01A", "TCGA-A4-8630-01A", "TCGA-A4-A4ZT-01A", "TCGA-A4-A5DU-01A", 
"TCGA-AK-3426-01A", "TCGA-AK-3429-01A", "TCGA-AK-3451-01A", "TCGA-AK-3456-01A", 
"TCGA-AK-3458-01A", "TCGA-AK-3465-01A", "TCGA-AL-3468-01A", "TCGA-B0-4691-01A", 
"TCGA-B0-4699-01A", "TCGA-B0-4823-01A", "TCGA-B0-4843-01A", "TCGA-B0-4845-01A", 
"TCGA-B0-5084-01A", "TCGA-B0-5085-01A", "TCGA-B0-5092-01A", "TCGA-B0-5119-01A", 
"TCGA-B0-5120-01A", "TCGA-B0-5693-01A", "TCGA-B0-5696-01A", "TCGA-B0-5697-01A", 
"TCGA-B0-5701-01A", "TCGA-B1-A47N-01A", "TCGA-B2-5633-01A", "TCGA-B3-4104-01A", 
"TCGA-B4-5834-01A"), class = "data.frame")

Desired output (sample):

enter image description here

melolilili
  • 239
  • 1
  • 8
  • 1
    You probably have to use `print(ggplot....)` inside the `for_loop`. Here is another SO answer you may have a look to: https://stackoverflow.com/questions/15678261/ggplot-does-not-work-if-it-is-inside-a-for-loop-although-it-works-outside-of-it – MarBlo Nov 20 '22 at 06:29
  • The error message says that the first argument to ggplot, `data=` must be a data frame. Your code has `df[,i]` which is not a data frame. Replacing it with `df` generates the error "Error: Discrete value supplied to a continuous scale." – dcarlson Nov 20 '22 at 22:03

0 Answers0