7  Plotting Basics

We explore plotting using dilution series data as an example

7.1 Libraries

The package ggpmisc will only be used once in this chapter. It provides additional functions for the annotating and plotting of fitted models

7.2 Import Datasets

We import a lipidomics dataset in a flat table with additinal columns indicating QC types, injection volumes, and dilution series number

d_orig <- read_csv(here("data/Testdata_Lipidomics_flat_wide_annotated_V1.csv"))

?(caption)

DataFileName QCtype CurveNo InjVol CE 16:0 CE 16:1 CE 16:2 CE 17:0 CE 17:1 CE 18:0 CE 18:1 CE 18:1 d7 (ISTD) CE 18:2 CE 18:3 CE 20:1 CE 20:2 CE 20:3 CE 20:4 CE 20:5 CE 22:0 CE 22:1 CE 22:4 CE 22:5 CE 22:6 CE 24:4 Cer d18:0/16:0 Cer d18:0/18:0 Cer d18:0/20:0 Cer d18:0/22:0 Cer d18:0/22:0 [284] Cer d18:0/24:1 Cer d18:0/24:1 [284] Cer d18:1/16:0 Cer d18:1/16:0 d31 (ISTD) Cer d18:1/17:0 Cer d18:1/18:0 Cer d18:1/20:0 Cer d18:1/22:0 Cer d18:1/24:0 Cer d18:1/24:1 Cer d18:1/25:0 Cer d18:1/26:0 Cer d18:2/22:0 Cer d18:2/24:1 COH [161) COH [95) DG 14:0_18:1 [-14:0] DG 14:0_18:1 [-18:1] DG 14:0_18:2 [-14:0] DG 14:0_18:2 [-18:2] DG 15:0_18:1 d7 (ISTD) [-15:0] DG 15:0_18:1 d7 (ISTD) [-18:1] DG 16:0_16:0 [-16:0] DG 16:0_16:1 [-16:0] DG 16:0_16:1 [-16:1] DG 16:0_18:1 [-16:0] DG 16:0_18:1 [-18:1] DG 16:0_18:2 [-16:0] DG 16:0_18:2 [-18:2] DG 16:0_20:3 [-20:3] DG 16:0_20:4 [-20:4] DG 16:0_22:5 [-22:5] DG 16:0_22:6 [-22:6] DG 16:1_18:1 [-16:1] DG 16:1_18:1 [-18:1] DG 18:0_18:1 [-18:0] DG 18:0_18:1 [-18:1] DG 18:0_18:2 [-18:0] DG 18:0_18:2 [-18:2] DG 18:0_20:4 [-20:4] DG 18:1_18:1 [-18:1] DG 18:1_18:2 [-18:1] DG 18:1_18:2 [-18:2] DG 18:1_18:3 [-18:3] DG 18:1_20:3 [-20:3] DG 18:1_20:4 [-18:1] DG 18:1_20:4 [-20:4] DG 18:2_18:2 [-18:2] DG 18:2_20:3 [-20:3] DG 18:2_20:4 [-20:4] Diisooctyl Phthalate GM3 d18:1/16:0 GM3 d18:1/18:0 GM3 d18:1/20:0 GM3 d18:1/22:0 GM3 d18:1/24:0 GM3 d18:1/24:1 Hex2Cer d18:1/16:0 Hex2Cer d18:1/16:0 d3 (ISTD) Hex2Cer d18:1/18:0 Hex2Cer d18:1/20:0 Hex2Cer d18:1/22:0 Hex2Cer d18:1/24:0 Hex2Cer d18:1/24:1 Hex3Cer d18:1/16:0 Hex3Cer d18:1/18:0 Hex3Cer d18:1/20:0 Hex3Cer d18:1/22:0 Hex3Cer d18:1/24:0 Hex3Cer d18:1/24:1 HexCer d18:1/16:0 HexCer d18:1/16:0 d3 (ISTD) HexCer d18:1/18:0 HexCer d18:1/20:0 HexCer d18:1/22:0 HexCer d18:1/24:0 HexCer d18:1/24:1 LPC 14:0 LPC 15:0 LPC 16:1 LPC 17:0 LPC 17:1 LPC 18:0 LPC 18:1 LPC 18:1 d7 (ISTD) LPC 18:2 LPC 18:3 LPC 19:0 LPC 19:1 LPC 20:0 LPC 20:1 LPC 20:2 LPC 20:3 LPC 20:4 LPC 20:5 LPC 22:0 LPC 22:1 LPC 22:5 LPC 22:6 LPC 24:0 LPC 26:0 LPC O-16:0 LPC O-18:0 LPC O-18:1 LPC O-20:0 LPC O-20:1 LPC O-22:0 LPC O-22:1 LPC O-24:0 LPC P-16:0 LPC P-18:0 LPC P-18:1 LPC P-20:0 LPE 16:0 LPE 18:0 LPE 18:1 LPE 18:1 d7 (ISTD) LPE 18:2 LPE 20:4 LPE 22:6 LPE P-16:0 LPE P-18:0 LPE P-18:1 LPI 20:4 LPS 16:0 LPS 18:0 LPS 18:1 LPS 18:2 PC 31:0 PC 31:1 PC 32:0 PC 32:1 PC 32:2 PC 32:3 PC 33:1 PC 33:1 d7 (ISTD) PC 33:2 PC 34:0 PC 34:1 PC 34:2 PC 34:2 + 2O PC 34:2 + OO-34:3 +2OP-34:2 +2O PC 34:3 PC 34:4 PC 34:5 PC 35:1 PC 35:2 PC 35:3 PC 35:4 PC 35:5 PC 36:1 PC 36:2 PC 36:3 PC 36:4 a PC 36:4 b PC 36:5 PC 36:6 PC 36:7 PC 37:4 PC 37:5 PC 37:6 PC 38:3 PC 38:4 PC 38:5|PC 38:6 [M+2] PC 38:6 PC 38:7 PC 38:8 PC 39:5 PC 39:6 PC 39:7 PC 40:4|PC 40:5 [M+2]|PC 40:6 [M+4] PC 40:5|PC 40:6 [M+2] PC 40:6 PC 40:7 PC 40:8 PC O-32:0 PC O-32:1 PC O-32:2 PC O-34:1 PC O-34:2 PC O-34:4 PC O-36:1 PC O-36:2 PC O-36:4 PC O-36:5 PC O-38:4 PC O-38:5 PC O-38:6 PC O-40:5 PC O-40:6 PC O-40:7 PC P-32:0 PC P-32:1 PC P-34:1 PC P-34:2 PC P-34:3 PC P-36:2 PC P-36:4 PC P-36:5 PC P-38:4 PC P-38:5 PC P-40:5 PC P-40:6 PE 32:1 PE 33:1 d7 (ISTD) PE 34:0 PE 34:1 PE 34:2 PE 34:3 PE 35:1 PE 35:2 PE 36:1 PE 36:2 PE 36:3|PE 36:4 [M+2] PE 36:4 a PE 36:4 b PE 36:5 PE 37:5 PE 38:3 PE 38:4 PE 38:5 PE 38:6 PE 40:4 PE 40:5|PE 40:6 [M+2] PE 40:6 PE 40:7 PE O-34:1 PE O-34:2 PE O-36:2 PE O-36:3 PE O-36:5 PE O-38:4 PE O-38:5 PE O-40:5 PE O-40:6 PE O-40:7 PE P-16:0/18:1 [FA] PE P-16:0/18:1 [head group] PE P-16:0/18:2 [FA] PE P-16:0/18:2 [head group] PE P-16:0/20:4 [FA] PE P-16:0/20:4 [head group] PE P-16:0/22:5 [FA] PE P-16:0/22:5 [head group] PE P-16:0/22:6 [FA] PE P-16:0/22:6 [head group] PE P-18:0/18:1 [FA] PE P-18:0/18:1 [head group] PE P-18:0/18:2 [FA] PE P-18:0/18:2 [head group] PE P-18:0/20:4 [FA] PE P-18:0/20:4 [head group] PE P-18:0/22:5 [FA] PE P-18:0/22:5 [head group] PE P-18:0/22:6 [FA] PE P-18:0/22:6 [head group] PE P-20:0/20:4 [FA] PE P-20:0/20:4 [head group] PE P-34:1 [-141] PE P-34:2 [-141] PE P-36:2 [-141] PE P-36:3 [-141] PE P-36:4 [-141] PE P-38:4 [-141] PE P-38:5 [-141] PE P-38:6 [-141] PE P-40:5 [-141] PE P-40:6 [-141] PG 33:1 d7 (ISTD) PG 34:1 PG 36:1 PG 36:2 PI 32:0 PI 32:1 PI 33:1 d7 (ISTD) PI 34:0 PI 34:1 PI 34:2 PI 35:1 PI 35:2 PI 36:1 PI 36:2 PI 36:3|PI 36:4 [M+2] PI 36:4 PI 36:5 PI 37:4 PI 38:3 PI 38:4 PI 38:5 PI 38:6 PI 40:4 PI 40:5|PI 40:6 M+2 PI 40:6 polysiloxane 7 polysiloxane 8 PS 33:1 d7 (ISTD) SM 30:1 SM 31:1 SM 32:0 SM 32:1 SM 32:2 SM 33:1 SM 34:0 SM 34:1 SM 34:2 SM 34:3 SM 35:1 SM 35:2 SM 36:1 SM 36:2 SM 36:2 d9 (ISTD) SM 36:3 SM 38:1 SM 38:2 SM 38:3 SM 39:1 SM 40:1 SM 40:2 SM 40:3|PC 36:4 M+1 SM 41:1 SM 42:1 SM 42:2 SM 42:3 SM 43:1 SM 44:1 SM 44:2 TG 48:0 TG 48:0 [-16:0] TG 48:1 TG 48:1 [-18:1] TG 48:1 d7 (ISTD) TG 48:1 d7 [-15:0] (ISTD) TG 48:2 TG 48:2 [-14:1] TG 48:2 [-16:0] TG 48:2 [-16:1] TG 48:2 [-18:1] TG 48:3 TG 48:3 [-16:1] TG 48:3 [-18:2] TG 49:1 TG 49:1 [-15:0] TG 49:1 [-16:0] TG 49:1 [-18:1] TG 50:0 TG 50:0 [-18:0] TG 50:1 TG 50:1 [-14:0] TG 50:1 [-18:1] TG 50:2 TG 50:2 [-18:0] TG 50:2 [-18:1] TG 50:2 [-18:2] TG 50:3 TG 50:3 [-14:1] TG 50:3 [-16:1] TG 50:3 [-18:1] TG 50:4 TG 50:4 [-14:0] TG 51:0 [-16:0] TG 51:0 [-17:0] TG 51:1 TG 51:1 [-18:1] TG 51:2 TG 51:2 [-15:0] TG 51:2 [-16:0] TG 51:2 [-18:1] TG 52:1 TG 52:1 [-18:0] TG 52:2 TG 52:2 [-16:0] TG 52:3 TG 52:3 [-16:1] TG 52:3 [-18:2] TG 52:4 TG 52:4 [-16:0] TG 52:4 [-18:1] TG 53:2 TG 53:2 [-17:0] TG 54:1 TG 54:1 [-18:1] TG 54:2 TG 54:2 [-18:0] TG 54:3 TG 54:3 [-18:1] TG 54:4 TG 54:4 [-18:0] TG 54:4 [-18:2] TG 54:5 TG 54:5 [-18:1] TG 54:6 TG 54:6 [-18:2] TG 56:6 TG 56:6 [-20:4] TG 56:8 TG 56:8 [-20:4] TG 58:8 TG 58:8 [-22:6]
007_ExtrBLK+ISTD01.d PBLK NA 1.0 286 176 3 138 62 59 3428 689555 10116 376 274 69 149 4192 1447 68 13 8 541 677 95 299 151 370 879 84 747 60 296 52921 76 504 445 561 2002 601 115 577 81 50 930 758 68 227 27 72 46210 35538 12075 27 443 986 755 114 788 NA 17 33 74 680 1121 366 347 186 446 90 2580 1276 1677 102 77 0 79 575 86 6 10884476 296 40 NA 11 3 15 130 19588 169 11 77 43 5 101 11 14 18 4 18 4 81 483 NA 11 35 173 343 1899 1641 1394 194 45993 14271 743063 8866 261 315 342 52 306 313 773 4746 404 84 46 776 374 21 3978 554 243 567 2 24 NA 7 10 118 146 19 5 197 203 473 30320 273 105 116 5 52 5 9 3 36 9 14 2337 127 5482 4179 1014 56 2544 5364027 2055 3028 50186 220121 8836 3371 12841 3739 439 7315 6255 3550 4741 555 44677 193527 66604 8948 74075 15242 1398 139 7389 4445 715 29878 218128 116602 31502 1950 1604 1697 1368 664 10408 28746 32564 3049 1174 727 154 223 3945 1504 63496 120 1971 10601 2625 3839 10068 1570 599 33 749 667 124 2145 1528 63496 947 3496 2430 2586 2146 84 103 119 85385 37 732 1521 1501 75 4 593 3321 769 141 948 82 3 24 1387 643 354 56 150 125 3 12 2 112 63 5 377 15 85 NA NA 84 46 12 24 250 185 47 10 41 5 40 27 38 11 189 62 167 7 152 53 8 6 NA 3 6 6 NA 15 28 9 6 65 274588 134 11 1276 300 39 43018 74 186 564 NA 5 87 890 33 169 39 121 344 3313 428 74 171 174 4 70768 180139 25363 58 77 64 1406 170 1618 3123 55411 4064 17 1835 55 10333 4775 582952 105 4115 6898 391 2878 13648 3948 64752 6403 5377 14692 615 803 324 315 69292 157096 87824 14097 1223048 1155057 79678 2246 9701 38124 7483 19294 10544 1721 310114 12002 14803 10859 82977 59094 73204 1860 32582 82248 1562 18063 6893 27208 729 12103 5169 8014 96 6051 5371 59691 7676 32008 1599 3712 8119 62496 13275 93624 26525 57316 5563 11115 39649 3334 2364 12603 1530 31678 2391 44729 7425 66343 33337 545312 704 1584 61815 3630 20502 1958 12937 572 7188 267 11468 51
009_NIST_NIST01.d NIST NA 1.0 127473 63573 1354 4352 10483 25764 2783175 738212 13162658 268666 2432 22891 750424 4331803 440531 159 289 33936 119603 469990 2819 2032 2507 3130 13689 4089 163978 3598 20578 58137 407 9578 9657 109670 474960 128787 5898 5495 13298 15250 62026 75898 4694 6308 2939 4740 23752 25514 25321 9300 7985 65222 86007 36817 72652 3515 11053 3842 2715 19179 15307 9694 10912 9669 9996 3978 166263 102995 127856 14601 6590 2967 26302 53036 3774 9941 12028398 22791 6010 3205 4061 4856 4056 106803 19758 1327 219 5130 6301 18680 22473 8010 506 3691 5062 6070 201817 65013 6262 3772 39476 64282 41399 137314 81574 346927 130496 24036 3794250 2898079 1028806 3046211 50027 9119 5646 9732 19749 27292 231721 750717 37843 2648 1431 56154 101253 3547 12303 108525 25048 86960 4571 4829 4705 5904 10741 35194 3148 4106 3780 19083 25955 20755 32941 32608 14350 6862 2360 2322 961 970 3520 732 375 353 107170 12343 2144857 4292903 281378 5590 524947 6948171 577516 291150 26218795 72538161 499424 481548 2793917 154926 8551 622151 1094257 326459 142848 3259 2673755 28758469 16938446 3594098 19641161 1585119 33128 675 588800 175758 27043 4266329 11203851 8258775 13240020 84571 3575 245280 82061 13853 426518 1049393 1769673 619813 75505 300743 93996 13065 577991 834438 243929 40578 176994 2335966 93378 812063 1756614 62520 159494 120383 146460 253160 53650 411874 1222791 243929 216928 1354951 85965 379378 697564 126608 39892 18069 72411 1591 70238 114781 11020 2543 3712 51482 289573 96921 33207 165189 8842 1431 36141 307092 113882 430302 9090 32529 77145 22208 5985 8418 8972 9036 1882 37007 49305 7587 5891 7340 7787 12375 25305 23644 92100 95195 30551 17864 52029 30229 10421 9987 45057 58485 171670 168714 13585 14555 35227 38250 8036 9595 2377 6919 15024 42958 12554 37074 47238 16703 12986 10628 309207 2827 1351 8581 4483 14210 52508 8924 77584 83305 1663 4135 89470 234090 62510 58141 1040 4738 248874 564977 52061 8225 28222 28282 16498 90063 139562 79878 29418 15895 40053 987604 80064 576029 3841275 36009635 2099380 13225 661530 76583 4254255 5493318 2042574 153261 2204192 1053841 133281 704683 4426105 3414587 21053767 1445846 2265186 7185614 3458279 104401 9260 37478 1713850 2579195 4259047 1609938 1088468 1077786 2996868 201403 1147437 929866 833735 940461 182196 309810 606252 141427 240862 183495 1980468 1297072 12311881 130839 7056648 16533433 93602 4895184 2716242 8832187 81948 2630841 1440570 2009639 234563 55377 38042 793988 321167 1370133 137899 315528 560791 10189061 3297740 38252501 11964607 37500101 1261912 10354682 24520756 4653990 2635978 904734 212152 1392636 315694 7311102 2153844 12461871 8145577 12948806 367959 924028 11723013 1918808 5831344 843191 3314241 356905 1117741 121504 610872 62389
010_TQC-0perc.d RQC 1 0.0 176 208 43 69 32 21 775 88 4449 394 13 NA 324 2995 540 70 47 9 328 485 NA 262 96 345 785 20 920 43 499 163 NA 59 245 576 1951 107 97 650 NA 59 65 1216 83 48 73 76 67 81 13056 74 182 1053 1488 297 531 NA 33 NA 71 145 115 163 416 120 336 183 2292 807 1589 381 NA 0 96 406 NA 0 9621854 121 0 75 0 7 6 53 0 5 46 0 19 17 153 86 7 0 7 0 0 126 NA NA 21 5 21 288 255 1081 812 154 27944 9967 1206 7387 193 125 212 82 184 110 426 2931 249 92 12 359 247 56 39 522 156 281 5 8 21 18 60 153 18 66 40 254 153 525 50 136 38 125 13 11 NA 11 7 11 NA 5 508 154 3808 3178 1497 36 2043 7977 544 997 42277 130082 3146 3582 8252 2438 420 3193 2540 1136 1505 228 43477 145681 36696 11968 44258 7001 672 110 3820 2047 445 15850 100563 48640 15930 1041 333 1068 556 NA 3655 9078 14142 1077 777 412 105 71 1880 536 35 116 1185 6927 1132 3068 4810 293 186 514 32 76 71 556 1597 35 1086 1844 NA 1563 1008 390 267 0 87 16 1248 1787 929 234 66 195 2276 708 341 97 284 6 22 1422 117 62 50 139 150 4 23 3 68 4 10 82 42 204 2 52 NA 9 5 65 279 44 0 69 NA 20 64 143 97 5 255 52 110 45 82 5 22 46 4 4 7 13 NA 134 1 0 NA NA 133 166 0 1363 0 20 100 0 345 559 NA 68 2 268 306 433 55 0 67 2487 207 45 74 317 121 133566 435796 NA 59 63 NA 1103 53 1888 1196 45361 3665 30 1734 500 7304 2388 606 253 4118 1414 613 722 14459 6812 46493 3662 6282 15077 198 305 203 299 84832 130952 77481 13927 55692 485 72017 2107 9871 31049 7373 15593 8308 1625 67786 13271 17665 8660 71660 31531 73428 963 29587 84100 2063 20463 6554 32747 536 10082 4977 NA 30 4944 2760 32404 7362 24266 2011 4011 9419 46059 10004 83604 18932 42201 5155 15668 17497 3106 2170 11341 1221 25696 2122 28169 4117 45821 24443 22263 491 1666 14707 2711 21203 1189 9077 210 8244 148 7214 117
011_TQC-20perc.d RQC 1 0.2 61694 20572 1334 1793 6066 12630 1254932 122316 10162065 298819 1096 13190 355471 9214056 923462 83 41 27013 158402 490973 186 1353 1015 992 1856 518 21905 563 12154 12449 432 12612 7216 29933 61119 43403 1813 1238 2063 2478 67872 73909 824 1516 908 5 4762 4914 15414 1528 1187 9772 12150 10529 15260 825 5732 1862 1452 4205 4831 3845 4948 3980 6617 4510 44752 26787 34749 6103 2610 1208 9334 11170 865 8181 10404085 20565 7126 1653 1816 902 4125 23108 2958 2393 468 1010 1340 1201 3702 2402 619 387 519 728 42680 19104 1274 827 1704 2699 1737 39034 26830 187399 105172 15929 4638519 1126016 159574 930585 28405 17858 5507 5969 17237 17624 73068 495662 41901 1820 1342 68524 48665 1857 1550 37452 17252 40956 613 705 158 221 155 6778 1371 1083 966 10633 28832 9210 6740 7561 3868 1424 708 1940 641 274 714 1036 199 43 50683 5206 508068 693799 147071 7335 205200 1325752 199052 203669 6609328 29442224 756090 469800 1353212 77345 5025 487661 658999 251582 97587 3950 3694307 25860400 7523694 1451904 12283106 1354230 43142 1691 839878 296705 21466 3117178 24244982 12609444 5991185 153116 18565 127489 109214 11159 816180 2457044 3210928 527581 108967 78736 55214 13136 236840 183855 58394 22161 86525 1017511 133620 397755 1186140 154760 111815 118739 66732 37681 5551 111762 226915 58394 62617 320892 59986 174464 191838 51790 9855 4059 13910 1200 20037 40466 5735 1542 5198 20770 147044 52985 21955 60167 6198 1723 9818 210873 70869 182277 6369 29116 32769 12379 1692 2323 9762 2278 674 40687 32843 34161 7262 8337 792 898 1162 2324 6873 9560 6843 3517 9900 6187 2519 2215 6004 5316 26777 38186 7873 7506 5864 7466 521 427 116 366 1564 5837 1919 6078 15802 1573 13824 2680 50535 2737 489 9130 1712 1571 9490 15992 16417 23906 2078 2374 34472 66359 24239 36026 1114 3296 72903 298856 32144 3350 18084 13935 4693 202140 567223 16956 2934 4176 3487 116392 9371 230925 840399 7792418 459229 2809 366413 31604 1211164 1477662 275813 20060 303689 162667 30349 151902 493389 287821 12822011 347213 333465 1189392 59863 24272 4147 13270 691319 1067563 1138106 451759 347005 265272 587806 37355 152370 174334 180093 214514 48780 46771 407948 75885 124483 126712 1034646 586888 3872574 81522 1910499 3964718 67644 1451011 739644 1727153 25737 483618 360356 483880 36490 39829 29394 550179 158819 702224 69656 135707 288183 3711590 1614807 14927621 4037398 17539953 827120 3341124 5594760 928052 896321 604613 167787 722626 161911 3006890 1187016 7798572 4307841 11490319 360533 572420 5415961 966709 2483365 315246 2821175 374205 824005 100156 581948 43145
012_TQC-40perc.d RQC 1 0.4 117673 48622 1584 4550 12252 39588 2607941 315312 20199519 358757 3010 28641 615644 12485971 2182075 22 18 48920 339380 742016 1088 2857 3067 1466 3157 905 51812 981 15892 14277 1099 29760 15453 67207 142054 107122 3960 2146 3720 7831 69443 75636 2137 2048 1057 1045 10021 12896 19260 2397 3472 26870 37350 23633 29960 2126 11101 4436 1793 10244 10281 9138 9298 10737 14924 12429 89279 83036 74684 15247 5168 3441 19901 32067 5170 16341 10581631 58123 17612 3504 1217 2103 2156 58051 9087 6000 1219 3486 3053 3810 6222 3030 730 1408 1772 841 86015 52621 2457 3211 5596 6574 4951 89832 67649 429799 251299 38777 14838903 2954297 439570 2326507 64211 46124 13270 14168 52770 41843 186901 1327072 104006 4475 4069 174737 124183 5326 6499 83963 41191 88453 2048 1683 578 581 426 15963 3803 2469 1657 25231 68525 20087 13823 17964 8760 3073 1649 4835 1102 540 2127 2642 389 71 94942 13501 1291580 2022692 383311 14765 487825 3132381 557533 580772 13509625 53795455 1980420 1304889 4409903 206510 13448 1328407 1945259 543379 282428 10074 9844450 48720121 13790204 5014062 30950762 4635226 97396 3902 2386817 951059 55754 7625670 40784021 24718897 15246895 335989 37261 390578 249937 31709 1808005 4415291 6599016 1345593 356688 222909 152480 26521 731712 365189 164873 59171 236241 2368822 292476 1316157 2322290 216129 363011 187248 144267 71669 16449 302754 498029 164873 184480 848949 134693 369634 525392 179693 17709 5336 39522 2514 36898 82520 12722 5439 7179 55161 273642 114984 61084 135118 15179 8077 29162 416860 153189 397746 19739 50842 60793 28857 10002 3458 23793 4289 1608 88303 68892 74045 10752 13565 2300 2581 2015 3555 16283 23990 20928 11038 18572 11400 5157 5434 12282 13699 63213 83452 20527 21725 15600 23616 981 687 505 1121 3908 11139 4188 14255 36887 3646 30128 2901 103162 4790 1461 16959 3435 4539 21631 22318 42756 56618 4037 4010 88201 201309 43831 79562 2538 9759 219411 651807 79351 8537 52609 39001 13983 249091 466880 32406 7144 10316 8864 281206 24138 621646 1942572 27612222 984462 5721 963459 79113 2731227 3271466 872857 49650 951864 343967 63586 480738 1356196 880350 26167824 944484 760560 2595089 156848 67324 12250 34241 1106826 1499276 1958793 878979 721557 630266 1369952 92952 325846 409738 369498 471095 105790 119907 505906 116102 195811 186531 2064964 1278469 6308232 122047 3152024 7508103 131067 2883614 1073917 4378084 69767 1247724 800924 1123044 80643 76914 65275 849991 309751 1166669 86571 210298 436332 8728511 3398622 18913822 6316448 26768309 1509715 5763033 15066447 2493426 2551634 1232388 337260 1861349 483059 9173035 2772530 11508134 7918162 17142880 574890 922970 14148146 2612867 5794736 771570 5317616 548092 2069017 264968 1363608 126308
013_TQC-60perc.d RQC 1 0.6 156974 46748 2024 8108 16930 68171 3470512 430598 21175237 358670 5194 36523 941156 15466319 3178876 20 166 64374 295298 1019271 1093 2455 5664 1760 4773 1366 77299 1577 22712 29252 1029 30987 24735 94740 221862 170846 5837 3192 5717 12955 68640 76589 3317 5656 1124 1821 13733 19908 25348 3376 4540 36722 52281 30847 49311 2678 17022 8098 3713 14773 14711 13376 14782 14595 20999 18957 158583 113541 113038 16069 8255 4624 34243 39471 6560 17744 10800520 81852 26201 4035 2407 1712 5366 99707 15004 5621 2314 4274 3171 5472 10077 3194 905 1590 1699 2311 112728 92340 4039 4879 8147 9650 8163 139576 112760 659549 379460 61269 27286319 5041635 729528 3873034 95940 71581 22550 23901 94750 68859 315268 2167424 161473 7005 5334 294022 199385 7451 9408 154936 63400 162642 2787 3170 916 805 963 21785 5807 3963 2511 37996 99375 29740 21580 28558 13401 4862 2401 6981 2063 943 4056 4060 927 535 118345 26905 1770885 3171171 582064 22358 554965 4069666 869196 922882 18847354 61237414 3395370 1782637 7180931 342895 22164 2027915 2370170 970208 372987 12580 17980909 58785218 21383288 7037327 36135439 7153772 151948 5232 3295363 1295516 113871 11388561 45945289 30144206 22873131 555058 63994 606785 320774 50194 2802510 5778767 10096374 1789018 495586 353759 190798 39208 1199459 383518 240126 97139 410953 3429512 363644 1975318 3041881 213588 568661 186321 221778 138100 30523 437824 606467 240126 296127 1383135 151409 563884 715009 243522 32973 9492 69562 4743 48045 118034 17683 6246 15036 96662 353890 173216 67780 179887 20553 9808 47188 420527 234726 442814 26002 68646 84319 28701 13232 3948 33482 4666 1389 145695 82052 128864 14449 19943 4912 3259 5766 7267 27032 29049 30729 16266 23765 13039 8406 8311 19429 17165 122088 99755 28542 27565 24146 22617 1310 1456 1638 1144 7663 27329 3005 24735 58184 4093 54603 4377 205893 7216 2831 20434 6478 7855 34181 24434 59813 105520 5927 7393 69090 247296 73219 139031 4424 14417 236097 1242914 109192 13836 42954 49338 21254 65323 154719 35757 10606 14660 12594 445081 34161 937595 2552058 42448905 1466065 11104 1092522 117699 3872093 4521678 1210793 88135 1402276 418103 83241 821261 1935472 1388413 32999765 1551228 1163204 4298622 842475 101599 16069 46857 1162439 1822452 2843614 1077254 642714 862320 2002130 140325 577704 540820 599313 775705 162782 176731 559338 130203 199692 213629 2492710 1454644 7378543 159023 4355694 8366068 148504 3550924 1304357 6436755 95553 1391568 1157419 1738345 147102 104962 104262 1076069 380672 1277747 140647 268994 555391 12427530 3799514 29606799 7141771 31676652 1659674 7283898 20518296 3218666 2917170 1388816 366257 3204483 708824 9984047 4211767 16790868 8627074 22094513 591913 1106370 16952617 3448999 9164283 1337916 6502633 830651 3026281 364772 1687461 133587

7.3 Prepare Data

# Convert to long format
d_long <- d_orig|> 
  pivot_longer(cols = -DataFileName:-InjVol, 
               names_to = "Lipid" , 
               values_to = "Area")

# Get a table with RQCs only and sort by Lipid
d_rqc <- d_long |> 
  filter(QCtype == "RQC") |> 
  arrange(Lipid)

#Have a look at the table using View(d_rqc)

7.4 Plot a single curve

#Select data from one single lipid from dilution curve
d_forplot <- d_rqc  |> filter(Lipid == "LPC 16:1", CurveNo == 1)
DataFileName QCtype CurveNo InjVol Lipid Area
010_TQC-0perc.d RQC 1 0.0 LPC 16:1 1081
011_TQC-20perc.d RQC 1 0.2 LPC 16:1 187399
012_TQC-40perc.d RQC 1 0.4 LPC 16:1 429799
013_TQC-60perc.d RQC 1 0.6 LPC 16:1 659549
014_TQC-80perc.d RQC 1 0.8 LPC 16:1 905868
015_TQC-100perc.d RQC 1 1.0 LPC 16:1 1085113

7.5 Plotting one curve

ggplot(d_forplot, aes(x = InjVol, y = Area)) + 
  geom_point(size =5, color="red") +
  #geom_line() +
  scale_x_continuous(name = "Injection Volume", limits = c(-0.1, NA)) + 
  labs(title = "Response of LPC 16:1", y = "Peak Area [CPS]") +
  geom_smooth(method = "lm",se = TRUE, color = "blue", linetype = "dotted") +
  theme_light()

plot(
  x = d_forplot$InjVol,
  y = d_forplot$Area,
  pch = 16,
  cex = 1.5,
  col = "red",
  xlab = "Injection Volume",
  ylab = "Peak Area [CPS]",
  main = "Response of LPC 16:1"
)
abline(lm(Area ~ InjVol, data = d_forplot), col = "blue")

# more work will be needed to plot confidence intervals

7.6 Plotting multiple curves

#Select data from one single lipid from ALL dilution curves
d_forplot_2 <- d_rqc  |> filter(Lipid == "LPC 16:1")

ggplot(d_forplot_2, aes(x = InjVol, y = Area, color = factor(CurveNo))) + 
  geom_point(size =5) +
  scale_x_continuous(name = "Injection Volume", limits = c(0, NA)) + 
  labs(title = "Response of LPC 16:1", y = "Peak Area [CPS]") +
  geom_smooth(method = "lm", se = FALSE, linetype = "dotted") +
  theme_light()

7.7 Faceted plot from different lipids of one curve

#Select data from all LPCs from  dilution curve 1
d_forplot_3 <- d_rqc  |> filter(str_detect(Lipid, "LPC 2"), CurveNo == 2)

ggplot(d_forplot_3, aes(x = InjVol, y = Area, color = factor(CurveNo))) + 
  geom_point(size = 2) +
  scale_x_continuous(name = "Injection Volume", limits = c(0, NA)) + 
  labs(title = "Response Curves", y = "Peak Area [CPS]") +
  geom_smooth(method = "lm", se = FALSE, linetype = "dotted", size = 0.6) +
  facet_wrap(~Lipid, scales = "free") +
  theme_light(base_size = 8)

7.8 Add \(R^2\) to the plots

# Plot
ggplot(data = d_forplot_3, aes(x = InjVol, y = Area, 
                               group = factor(CurveNo))) +
  stat_poly_line() +
  stat_poly_eq(
    aes(
      label = after_stat(rr.label),
      color = if_else(after_stat(r.squared) < 0.96, "red", "black")
    ),
  size = 2.4,
  lineheight = 1111.5) +
  scale_color_identity() +
  scale_y_continuous(limits = c(0, NA)) +
  facet_wrap( ~ Lipid, scales = "free") +
  geom_point() + theme_light(base_size = 6)
#> Warning: Removed 62 rows containing missing values (geom_smooth).

7.9 Faceted plot from different lipids of all curves

#Select data from all LPCs from  dilution curve 1
d_forplot_4 <- d_rqc  |> filter(str_detect(Lipid, "LPC 2"))

ggplot(d_forplot_4, aes(x = InjVol, y = Area, 
                        color = factor(CurveNo))) + 
  geom_point(size = 2) +
  scale_x_continuous(name = "Injection Volume", limits = c(0, NA)) + 
  labs(title = "Response Curves", y = "Peak Area [CPS]") +
  geom_smooth(method = "lm", se = FALSE, 
              linetype = "dotted", size = 0.6) +
  facet_wrap(~Lipid, scales = "free") +
  theme_light(base_size = 8)

7.10 Faceted plots over multiple pages

One option is to use `ggforce::facet_wrap_paginate()` but this function can be slow and has some bugs with large datasets. Here an alternative way using *purrr::map()*

# Define function to plot 1 page
plot_page <-
  function(d, rows_page, columns_page) {
    ggplot(data = d, aes(x = InjVol , y = Area, group = factor(CurveNo))) +
      stat_poly_line() +
      stat_poly_eq(aes(
        label = after_stat(rr.label),
        color = ifelse(after_stat(r.squared) < 0.80, "red", "darkgreen")
      ), size = 1.4) +
      scale_color_identity() +
      scale_y_continuous(limits = c(0, NA)) +
      facet_wrap(vars(Lipid),
      scales = "free",
      nrow = rows_page,
      ncol = columns_page) +
      geom_point() + theme_light(base_size = 6)
  }

# Select all LPCs
d_forplot_5 <- d_rqc  |> filter(str_detect(Lipid, "LPC "), CurveNo == 2)

# Interate through pages


rows_page = 4
columns_page = 5

d_rqc_grp <- d_forplot_5 %>%
  left_join(tibble(Lipid = unique(.$Lipid)) |>
              mutate(grp = ceiling(row_number() / (rows_page * columns_page)))) %>%
  group_by(grp) %>%
  nest() %>%
  mutate(plt = map(data, ~ plot_page(.,rows_page =  rows_page, columns_page =  5)))

# Print pages 

d_rqc_grp$plt
#> Warning: Removed 101 rows containing missing values (geom_smooth).
#> Warning: Removed 1 rows containing non-finite values (stat_poly_line).
#> Warning: Removed 1 rows containing non-finite values (stat_poly_eq).
#> Warning: Removed 56 rows containing missing values (geom_smooth).
#> Warning: Removed 1 rows containing missing values (geom_point).

7.11 Save multi-page plot a PDF

pdf(file = "dilutions.pdf", onefile = TRUE, paper = "A4r", width = 11)
d_rqc_grp$plt$plt
dev.off()