Newbie R user here. I want to create a plot with boxplots of read length distribution on the Y-axis, and samples on the X-axis -- like this image from doi: 10.1038/srep16498
However, I'm not sure how to plot my data in ggplot2
to make this. My data is currently in this format:
Length Sample1 Sample2
20 10 5
30 15 223
40 16 4923
50 293 239
60 3290 23
70 248 6
80 23 1
90 21 0
100 5 0
Length is the read length bin, with the sample columns containing the number of reads of that length. I've tried using ggplot2
, but don't think I can do it with the data in its current format.
Thanks!
Edit: Here are the number of reads for each individual read length (converted to long format):
"Readlength" "name" "value"
"1" 25 "Sample1" 457
"2" 25 "Sample2" 580
"3" 26 "Sample1" 603
"4" 26 "Sample2" 648
"5" 27 "Sample1" 599
"6" 27 "Sample2" 715
"7" 28 "Sample1" 686
"8" 28 "Sample2" 914
"9" 29 "Sample1" 796
"10" 29 "Sample2" 1018
"11" 30 "Sample1" 1009
"12" 30 "Sample2" 1366
"13" 31 "Sample1" 1225
"14" 31 "Sample2" 1653
"15" 32 "Sample1" 1579
"16" 32 "Sample2" 2135
"17" 33 "Sample1" 1817
"18" 33 "Sample2" 2678
"19" 34 "Sample1" 2322
"20" 34 "Sample2" 3424
"21" 35 "Sample1" 2861
"22" 35 "Sample2" 4167
"23" 36 "Sample1" 3460
"24" 36 "Sample2" 5220
"25" 37 "Sample1" 4161
"26" 37 "Sample2" 6088
"27" 38 "Sample1" 4930
"28" 38 "Sample2" 7609
"29" 39 "Sample1" 5910
"30" 39 "Sample2" 9308
"31" 40 "Sample1" 7007
"32" 40 "Sample2" 11062
"33" 41 "Sample1" 8339
"34" 41 "Sample2" 13341
"35" 42 "Sample1" 10105
"36" 42 "Sample2" 16288
"37" 43 "Sample1" 11720
"38" 43 "Sample2" 19023
"39" 44 "Sample1" 13312
"40" 44 "Sample2" 22152
"41" 45 "Sample1" 15430
"42" 45 "Sample2" 25360
"43" 46 "Sample1" 17515
"44" 46 "Sample2" 28789
"45" 47 "Sample1" 20022
"46" 47 "Sample2" 32985
"47" 48 "Sample1" 22825
"48" 48 "Sample2" 38019
"49" 49 "Sample1" 26150
"50" 49 "Sample2" 42972
"51" 50 "Sample1" 28998
"52" 50 "Sample2" 49293
"53" 51 "Sample1" 33236
"54" 51 "Sample2" 56239
"55" 52 "Sample1" 37302
"56" 52 "Sample2" 62791
"57" 53 "Sample1" 41212
"58" 53 "Sample2" 69865
"59" 54 "Sample1" 45683
"60" 54 "Sample2" 76922
"61" 55 "Sample1" 49844
"62" 55 "Sample2" 82906
"63" 56 "Sample1" 53833
"64" 56 "Sample2" 90092
"65" 57 "Sample1" 58486
"66" 57 "Sample2" 98194
"67" 58 "Sample1" 64650
"68" 58 "Sample2" 105602
"69" 59 "Sample1" 69514
"70" 59 "Sample2" 114319
"71" 60 "Sample1" 76202
"72" 60 "Sample2" 123807
"73" 61 "Sample1" 83273
"74" 61 "Sample2" 133289
"75" 62 "Sample1" 90783
"76" 62 "Sample2" 146387
"77" 63 "Sample1" 98805
"78" 63 "Sample2" 159302
"79" 64 "Sample1" 107247
"80" 64 "Sample2" 168856
"81" 65 "Sample1" 115200
"82" 65 "Sample2" 180408
"83" 66 "Sample1" 123359
"84" 66 "Sample2" 191083
"85" 67 "Sample1" 134258
"86" 67 "Sample2" 200708
"87" 68 "Sample1" 142179
"88" 68 "Sample2" 212830
"89" 69 "Sample1" 155549
"90" 69 "Sample2" 226788
"91" 70 "Sample1" 165425
"92" 70 "Sample2" 239063
"93" 71 "Sample1" 178681
"94" 71 "Sample2" 255338
"95" 72 "Sample1" 194293
"96" 72 "Sample2" 272725
"97" 73 "Sample1" 211417
"98" 73 "Sample2" 288512
"99" 74 "Sample1" 225639
"100" 74 "Sample2" 307752
"101" 75 "Sample1" 242618
"102" 75 "Sample2" 324919
"103" 76 "Sample1" 259391
"104" 76 "Sample2" 338429
"105" 77 "Sample1" 274041
"106" 77 "Sample2" 354866
"107" 78 "Sample1" 295365
"108" 78 "Sample2" 373456
"109" 79 "Sample1" 315802
"110" 79 "Sample2" 389945
"111" 80 "Sample1" 337826
"112" 80 "Sample2" 411033
"113" 81 "Sample1" 363906
"114" 81 "Sample2" 437069
"115" 82 "Sample1" 388803
"116" 82 "Sample2" 460419
"117" 83 "Sample1" 416728
"118" 83 "Sample2" 487959
"119" 84 "Sample1" 446797
"120" 84 "Sample2" 518295
"121" 85 "Sample1" 474343
"122" 85 "Sample2" 538191
"123" 86 "Sample1" 496615
"124" 86 "Sample2" 558646
"125" 87 "Sample1" 524080
"126" 87 "Sample2" 583043
"127" 88 "Sample1" 549720
"128" 88 "Sample2" 601107
"129" 89 "Sample1" 573864
"130" 89 "Sample2" 623715
"131" 90 "Sample1" 604559
"132" 90 "Sample2" 648209
"133" 91 "Sample1" 632324
"134" 91 "Sample2" 668883
"135" 92 "Sample1" 657924
"136" 92 "Sample2" 698291
"137" 93 "Sample1" 686875
"138" 93 "Sample2" 727313
"139" 94 "Sample1" 712778
"140" 94 "Sample2" 745380
"141" 95 "Sample1" 732786
"142" 95 "Sample2" 766930
"143" 96 "Sample1" 755081
"144" 96 "Sample2" 784337
"145" 97 "Sample1" 772734
"146" 97 "Sample2" 793358
"147" 98 "Sample1" 787861
"148" 98 "Sample2" 804737
"149" 99 "Sample1" 807004
"150" 99 "Sample2" 820443
"151" 100 "Sample1" 823211
"152" 100 "Sample2" 826114
"153" 101 "Sample1" 836362
"154" 101 "Sample2" 839164
"155" 102 "Sample1" 853124
"156" 102 "Sample2" 853144
"157" 103 "Sample1" 865378
"158" 103 "Sample2" 861670
"159" 104 "Sample1" 874578
"160" 104 "Sample2" 875069
"161" 105 "Sample1" 887322
"162" 105 "Sample2" 883285
"163" 106 "Sample1" 888977
"164" 106 "Sample2" 875065
"165" 107 "Sample1" 889700
"166" 107 "Sample2" 877648
"167" 108 "Sample1" 893138
"168" 108 "Sample2" 875875
"169" 109 "Sample1" 887592
"170" 109 "Sample2" 865221
"171" 110 "Sample1" 888684
"172" 110 "Sample2" 863268
"173" 111 "Sample1" 887037
"174" 111 "Sample2" 863513
"175" 112 "Sample1" 887121
"176" 112 "Sample2" 855519
"177" 113 "Sample1" 883085
"178" 113 "Sample2" 854312
"179" 114 "Sample1" 886536
"180" 114 "Sample2" 855445
"181" 115 "Sample1" 875703
"182" 115 "Sample2" 844795
"183" 116 "Sample1" 870749
"184" 116 "Sample2" 837992
"185" 117 "Sample1" 863969
"186" 117 "Sample2" 830157
"187" 118 "Sample1" 849188
"188" 118 "Sample2" 809476
"189" 119 "Sample1" 840690
"190" 119 "Sample2" 798965
"191" 120 "Sample1" 834472
"192" 120 "Sample2" 791200
"193" 121 "Sample1" 822558
"194" 121 "Sample2" 776191
"195" 122 "Sample1" 811864
"196" 122 "Sample2" 765913
"197" 123 "Sample1" 805300
"198" 123 "Sample2" 761200
"199" 124 "Sample1" 794602
"200" 124 "Sample2" 747483
"201" 125 "Sample1" 784650
"202" 125 "Sample2" 739639
"203" 126 "Sample1" 775107
"204" 126 "Sample2" 730152
"205" 127 "Sample1" 763282
"206" 127 "Sample2" 713285
"207" 128 "Sample1" 748652
"208" 128 "Sample2" 699446
"209" 129 "Sample1" 736764
"210" 129 "Sample2" 686165
"211" 130 "Sample1" 723134
"212" 130 "Sample2" 671281
"213" 131 "Sample1" 710686
"214" 131 "Sample2" 658314
"215" 132 "Sample1" 701834
"216" 132 "Sample2" 650564
"217" 133 "Sample1" 689531
"218" 133 "Sample2" 635331
"219" 134 "Sample1" 678070
"220" 134 "Sample2" 628475
"221" 135 "Sample1" 668757
"222" 135 "Sample2" 617210
"223" 136 "Sample1" 654506
"224" 136 "Sample2" 601336
"225" 137 "Sample1" 644720
"226" 137 "Sample2" 592700
"227" 138 "Sample1" 630305
"228" 138 "Sample2" 579707
"229" 139 "Sample1" 615571
"230" 139 "Sample2" 562022
"231" 140 "Sample1" 603896
"232" 140 "Sample2" 550812
"233" 141 "Sample1" 597816
"234" 141 "Sample2" 540016
"235" 142 "Sample1" 584121
"236" 142 "Sample2" 526066
"237" 143 "Sample1" 571689
"238" 143 "Sample2" 516774
"239" 144 "Sample1" 564142
"240" 144 "Sample2" 509033
"241" 145 "Sample1" 552281
"242" 145 "Sample2" 496389
"243" 146 "Sample1" 543184
"244" 146 "Sample2" 487283
"245" 147 "Sample1" 532683
"246" 147 "Sample2" 477035
"247" 148 "Sample1" 520019
"248" 148 "Sample2" 461698
"249" 149 "Sample1" 510484
"250" 149 "Sample2" 451095
"251" 150 "Sample1" 507832
"252" 150 "Sample2" 446390
"253" 151 "Sample1" 495343
"254" 151 "Sample2" 431015
"255" 152 "Sample1" 484169
"256" 152 "Sample2" 417551
"257" 153 "Sample1" 471422
"258" 153 "Sample2" 404674
"259" 154 "Sample1" 460944
"260" 154 "Sample2" 390280
"261" 155 "Sample1" 448227
"262" 155 "Sample2" 380134
"263" 156 "Sample1" 437738
"264" 156 "Sample2" 369703
"265" 157 "Sample1" 428359
"266" 157 "Sample2" 354902
"267" 158 "Sample1" 417445
"268" 158 "Sample2" 343343
"269" 159 "Sample1" 408065
"270" 159 "Sample2" 331193
"271" 160 "Sample1" 395244
"272" 160 "Sample2" 315775
"273" 161 "Sample1" 386510
"274" 161 "Sample2" 305048
"275" 162 "Sample1" 377028
"276" 162 "Sample2" 292336
"277" 163 "Sample1" 366563
"278" 163 "Sample2" 277876
"279" 164 "Sample1" 357659
"280" 164 "Sample2" 267642
"281" 165 "Sample1" 348242
"282" 165 "Sample2" 255871
"283" 166 "Sample1" 337553
"284" 166 "Sample2" 242636
"285" 167 "Sample1" 327824
"286" 167 "Sample2" 231054
"287" 168 "Sample1" 317584
"288" 168 "Sample2" 219066
"289" 169 "Sample1" 306454
"290" 169 "Sample2" 204829
"291" 170 "Sample1" 295255
"292" 170 "Sample2" 192423
"293" 171 "Sample1" 284770
"294" 171 "Sample2" 180440
"295" 172 "Sample1" 274444
"296" 172 "Sample2" 166529
"297" 173 "Sample1" 264469
"298" 173 "Sample2" 155605
"299" 174 "Sample1" 253923
"300" 174 "Sample2" 145166
"301" 175 "Sample1" 243462
"302" 175 "Sample2" 134932
"303" 176 "Sample1" 233021
"304" 176 "Sample2" 124474
"305" 177 "Sample1" 223360
"306" 177 "Sample2" 114975
"307" 178 "Sample1" 213341
"308" 178 "Sample2" 105267
"309" 179 "Sample1" 202191
"310" 179 "Sample2" 95632
"311" 180 "Sample1" 193325
"312" 180 "Sample2" 87027
"313" 181 "Sample1" 182022
"314" 181 "Sample2" 78802
"315" 182 "Sample1" 173011
"316" 182 "Sample2" 71116
"317" 183 "Sample1" 164207
"318" 183 "Sample2" 64758
"319" 184 "Sample1" 154985
"320" 184 "Sample2" 57082
"321" 185 "Sample1" 147070
"322" 185 "Sample2" 51728
"323" 186 "Sample1" 138927
"324" 186 "Sample2" 46295
"325" 187 "Sample1" 130203
"326" 187 "Sample2" 40908
"327" 188 "Sample1" 122935
"328" 188 "Sample2" 36275
"329" 189 "Sample1" 115565
"330" 189 "Sample2" 31825
"331" 190 "Sample1" 107969
"332" 190 "Sample2" 28028
"333" 191 "Sample1" 100995
"334" 191 "Sample2" 24447
"335" 192 "Sample1" 94510
"336" 192 "Sample2" 21125
"337" 193 "Sample1" 88365
"338" 193 "Sample2" 18489
"339" 194 "Sample1" 82247
"340" 194 "Sample2" 15878
"341" 195 "Sample1" 77315
"342" 195 "Sample2" 13881
"343" 196 "Sample1" 71657
"344" 196 "Sample2" 12183
"345" 197 "Sample1" 66920
"346" 197 "Sample2" 10305
"347" 198 "Sample1" 61298
"348" 198 "Sample2" 9096
"349" 199 "Sample1" 57765
"350" 199 "Sample2" 7759
"351" 200 "Sample1" 53811
"352" 200 "Sample2" 6645
"353" 201 "Sample1" 48906
"354" 201 "Sample2" 5532
"355" 202 "Sample1" 44847
"356" 202 "Sample2" 4642
"357" 203 "Sample1" 41546
"358" 203 "Sample2" 3997
"359" 204 "Sample1" 38125
"360" 204 "Sample2" 3360
"361" 205 "Sample1" 35039
"362" 205 "Sample2" 2858
"363" 206 "Sample1" 31902
"364" 206 "Sample2" 2447
"365" 207 "Sample1" 29076
"366" 207 "Sample2" 2185
"367" 208 "Sample1" 26271
"368" 208 "Sample2" 1811
"369" 209 "Sample1" 24037
"370" 209 "Sample2" 1494
"371" 210 "Sample1" 21487
"372" 210 "Sample2" 1313
"373" 211 "Sample1" 19187
"374" 211 "Sample2" 1028
"375" 212 "Sample1" 17317
"376" 212 "Sample2" 954
"377" 213 "Sample1" 15741
"378" 213 "Sample2" 819
"379" 214 "Sample1" 14000
"380" 214 "Sample2" 693
"381" 215 "Sample1" 12494
"382" 215 "Sample2" 614
"383" 216 "Sample1" 10963
"384" 216 "Sample2" 556
"385" 217 "Sample1" 9928
"386" 217 "Sample2" 549
"387" 218 "Sample1" 8652
"388" 218 "Sample2" 421
"389" 219 "Sample1" 7604
"390" 219 "Sample2" 404
"391" 220 "Sample1" 6515
"392" 220 "Sample2" 394
"393" 221 "Sample1" 5735
"394" 221 "Sample2" 325
"395" 222 "Sample1" 4783
"396" 222 "Sample2" 301
"397" 223 "Sample1" 4108
"398" 223 "Sample2" 308
"399" 224 "Sample1" 3611
"400" 224 "Sample2" 290
"401" 225 "Sample1" 3224
"402" 225 "Sample2" 307
"403" 226 "Sample1" 2676
"404" 226 "Sample2" 304
"405" 227 "Sample1" 2261
"406" 227 "Sample2" 273
"407" 228 "Sample1" 1936
"408" 228 "Sample2" 303
"409" 229 "Sample1" 1664
"410" 229 "Sample2" 302
"411" 230 "Sample1" 1529
"412" 230 "Sample2" 291
"413" 231 "Sample1" 1180
"414" 231 "Sample2" 313
"415" 232 "Sample1" 975
"416" 232 "Sample2" 288
"417" 233 "Sample1" 897
"418" 233 "Sample2" 274
"419" 234 "Sample1" 812
"420" 234 "Sample2" 281
"421" 235 "Sample1" 712
"422" 235 "Sample2" 318
"423" 236 "Sample1" 587
"424" 236 "Sample2" 288
"425" 237 "Sample1" 555
"426" 237 "Sample2" 299
"427" 238 "Sample1" 524
"428" 238 "Sample2" 314
"429" 239 "Sample1" 443
"430" 239 "Sample2" 336
"431" 240 "Sample1" 411
"432" 240 "Sample2" 354
"433" 241 "Sample1" 382
"434" 241 "Sample2" 339
"435" 242 "Sample1" 344
"436" 242 "Sample2" 342
"437" 243 "Sample1" 340
"438" 243 "Sample2" 366
"439" 244 "Sample1" 362
"440" 244 "Sample2" 353
"441" 245 "Sample1" 325
"442" 245 "Sample2" 373
"443" 246 "Sample1" 290
"444" 246 "Sample2" 340
"445" 247 "Sample1" 319
"446" 247 "Sample2" 345
"447" 248 "Sample1" 293
"448" 248 "Sample2" 341
"449" 249 "Sample1" 304
"450" 249 "Sample2" 365
"451" 250 "Sample1" 354
"452" 250 "Sample2" 381
"453" 251 "Sample1" 296
"454" 251 "Sample2" 366
"455" 252 "Sample1" 315
"456" 252 "Sample2" 415
"457" 253 "Sample1" 315
"458" 253 "Sample2" 399
"459" 254 "Sample1" 331
"460" 254 "Sample2" 377
"461" 255 "Sample1" 321
"462" 255 "Sample2" 410
"463" 256 "Sample1" 326
"464" 256 "Sample2" 421
"465" 257 "Sample1" 349
"466" 257 "Sample2" 433
"467" 258 "Sample1" 370
"468" 258 "Sample2" 429
"469" 259 "Sample1" 318
"470" 259 "Sample2" 439
"471" 260 "Sample1" 344
"472" 260 "Sample2" 433
"473" 261 "Sample1" 346
"474" 261 "Sample2" 400
"475" 262 "Sample1" 341
"476" 262 "Sample2" 419
"477" 263 "Sample1" 345
"478" 263 "Sample2" 499
"479" 264 "Sample1" 348
"480" 264 "Sample2" 418
"481" 265 "Sample1" 371
"482" 265 "Sample2" 454
"483" 266 "Sample1" 405
"484" 266 "Sample2" 441
"485" 267 "Sample1" 380
"486" 267 "Sample2" 476
"487" 268 "Sample1" 365
"488" 268 "Sample2" 464
"489" 269 "Sample1" 366
"490" 269 "Sample2" 461
"491" 270 "Sample1" 351
"492" 270 "Sample2" 483
"493" 271 "Sample1" 431
"494" 271 "Sample2" 481
"495" 272 "Sample1" 340
"496" 272 "Sample2" 503
"497" 273 "Sample1" 405
"498" 273 "Sample2" 493
"499" 274 "Sample1" 370
"500" 274 "Sample2" 529
"501" 275 "Sample1" 374
"502" 275 "Sample2" 469
"503" 276 "Sample1" 385
"504" 276 "Sample2" 503
"505" 277 "Sample1" 361
"506" 277 "Sample2" 496
"507" 278 "Sample1" 410
"508" 278 "Sample2" 491
"509" 279 "Sample1" 410
"510" 279 "Sample2" 521
"511" 280 "Sample1" 368
"512" 280 "Sample2" 514
"513" 281 "Sample1" 397
"514" 281 "Sample2" 501
"515" 282 "Sample1" 379
"516" 282 "Sample2" 546
"517" 283 "Sample1" 384
"518" 283 "Sample2" 502
"519" 284 "Sample1" 389
"520" 284 "Sample2" 513
"521" 285 "Sample1" 419
"522" 285 "Sample2" 571
"523" 286 "Sample1" 403
"524" 286 "Sample2" 519
"525" 287 "Sample1" 423
"526" 287 "Sample2" 536
"527" 288 "Sample1" 480
"528" 288 "Sample2" 653
"529" 289 "Sample1" 478
"530" 289 "Sample2" 564