2  Data reading

spverse reads the data provided by the user into the R environment and constructs it into an S4-class sp object. All subsequent analyses are performed based on this sp object.

2.1 Local spatial proteomics reading

  • Two files are required from the user for analyzing local spatial proteomics data.

  • One is a tab-delimited text file named “rawdata” (Table 1 shows the internal format of rawdata): the first column has a fixed header “Proteins”, containing IDs of different proteins or genes; the remaining columns have non-fixed headers corresponding to different spot names, and the values in these columns represent proteomic expression levels. (Note: spverse requires users to input data that has undergone log2 transformation.)

Table 1
Proteins sample1 sample2 sample3 sample4 sample5 … …
p1 xx xx xx xx xx xx
p1 xx xx xx xx xx xx
p3 xx xx xx xx xx xx
p4 xx xx xx xx xx xx
p5 xx xx xx xx xx xx
p6 xx xx xx xx xx xx
p7 xx xx xx xx xx xx
… … … … … … … … … … … … … …
  • The other file is a tab-delimited text file named “feature” (Table 2 illustrates its internal format): the first column has a fixed header “samples”, containing names of different spots; the remaining columns have non-fixed headers, and their contents correspond to the attribute features of the spot in that row, such as which individual it originates from and its prior classification.
Table 2
samples individual tumor_stroma
sample1 individual1 tumor
sample2 individual1 stroma
sample3 individual1 tumor
sample4 individual1 stroma
sample5 individual1 tumor
sample6 individual1 stroma
… … … … … …
  • When reading the data, the two aforementioned files must be stored in the same folder. This folder path is passed as the “pathway” parameter to the creatsp() function. The creatsp() function also has a “filetype” parameter, which represents the file extension (suffix) of the input files.
local_sp <- creatsp("D:/Rdata/zhc/article/part2/fan/s138",filetype = "xls")

print(local_sp)
sp data with 144 samples for 7428 features
  • The imported raw protein expression data is stored in the slot named rawdata.
head(local_sp@rawdata)
            N1_1-11  N1_1-12  N1_1-13   N1_1-14   N1_1-15   N1_1-16   N1_1-17
A0A075B6H9 8.474703 9.499059 8.785155 12.414688 13.161171 11.720077 11.429131
A0A075B6I0 6.867298 7.067208 6.849651  6.793079  7.444539  6.574342  6.472642
A0A075B6J9 5.411592 5.173726 4.794931  5.301442  5.763530  4.649232        NA
A0A075B6K2 3.710923       NA       NA  4.127387        NA        NA        NA
A0A075B6K4 5.886766 5.846282 5.547021  5.759162  6.261028  5.637051  5.580218
A0A075B6K5 5.624277 5.921010 5.199026  6.009886  6.525636  5.540127  5.859418
             N1_1-18   N1_1-19  N1_1-20  N1_1-21   N1_1-22   N1_2-11   N1_2-12
A0A075B6H9 11.881994 12.249536 8.613011 9.327196 10.678889 15.667441 15.919244
A0A075B6I0  6.803750  6.745124 7.517604 7.531681  6.743114 11.197273 11.765636
A0A075B6J9  5.753880  5.114896 5.040972 6.323951  4.824248  7.714746  9.232182
A0A075B6K2        NA  4.197648 4.277510 4.603449        NA  7.717506  8.850301
A0A075B6K4  5.767097  5.513427 5.968147 6.287270  5.457258  9.979352 10.546669
A0A075B6K5  5.558962  5.717246 6.325342 6.397137  5.804877 10.313574 10.539511
             N1_2-13   N1_2-14   N1_2-15   N1_2-16   N1_2-17   N1_2-18
A0A075B6H9 15.322222 15.217496 13.927722 15.473657 12.580478 12.648063
A0A075B6I0 11.202373 11.248219 10.581170 11.960973 10.567210 10.447906
A0A075B6J9  8.751367  8.888869  7.691024  9.473875  7.930623  7.772990
A0A075B6K2  8.386476  8.548910  8.117107  9.342531  7.881595  8.047332
A0A075B6K4 10.089257 10.177814  9.144018 10.634440  9.266425  9.327247
A0A075B6K5 10.440473 10.645758  9.670000 10.826482  9.792844  9.847210
             N1_2-19   N1_2-20   N1_2-21   N1_2-22  N2_1-11 N2_1-12  N2_1-13
A0A075B6H9 13.224027 12.146169 10.408711 14.899274 5.967562      NA 7.003577
A0A075B6I0 10.664634 11.067228  9.915960 11.648137 5.003117      NA 5.963721
A0A075B6J9  9.000817  8.156635  7.548385  9.929832 5.345243      NA 4.405344
A0A075B6K2  8.119788        NA  7.290159  8.856957       NA      NA 3.659464
A0A075B6K4  9.459425  9.845537  8.576126 10.214539 5.206099      NA 6.241992
A0A075B6K5  9.866661 10.257880  9.083679 10.717380 3.837363      NA 5.138194
            N2_1-14  N2_1-15  N2_1-16  N2_1-17  N2_1-18  N2_1-19  N2_1-20
A0A075B6H9 7.518226 5.288165 5.520438 4.923534 5.581278 6.327177 7.478687
A0A075B6I0 6.518871       NA       NA       NA       NA       NA 6.183934
A0A075B6J9       NA       NA 2.761738       NA       NA       NA 4.461236
A0A075B6K2       NA       NA       NA       NA       NA       NA 4.107261
A0A075B6K4 6.305775 4.533868 4.883211 4.963124 4.809912 5.441349 6.604844
A0A075B6K5 6.234811 3.392926 3.832933 4.020750 4.739800 4.487020 5.544942
            N2_1-21  N2_1-22  N2_2-11  N2_2-12  N2_2-13  N2_2-14  N2_2-15
A0A075B6H9 5.091268 6.939337 9.778879 9.175664 8.450348 7.259369 6.928311
A0A075B6I0       NA 5.801972 7.957112       NA 7.139250 6.274259 6.111713
A0A075B6J9       NA       NA 5.853537 4.921886 6.064773 4.563402 3.947981
A0A075B6K2       NA 3.305556       NA 5.250257 5.663554 4.497371 4.386012
A0A075B6K4 5.320771 5.791004 8.475808 7.802288 7.622681 6.029836 6.341426
A0A075B6K5 4.285481 4.925764 8.362614 7.735078 6.889493 6.038471 5.434141
            N2_2-16  N2_2-17  N2_2-18  N2_2-19  N2_2-20  N2_2-21  N2_2-22
A0A075B6H9 7.578197 9.028006 8.653360 7.888911 8.196567 6.788046 7.940889
A0A075B6I0 6.338711 7.407156 7.133082 6.540763 7.275704 5.539702 7.162091
A0A075B6J9 4.898237       NA 5.536787 5.060173 5.927664       NA       NA
A0A075B6K2       NA 6.213282 5.463000 4.055650 4.364168       NA 5.204971
A0A075B6K4 6.669146 8.081389 7.979071 7.053441 7.200382 5.813587 7.428008
A0A075B6K5 6.104365 7.378190 7.006243 6.641433 6.685727 5.375332 6.664885
            N5_1-11  N5_1-12  N5_1-13  N5_1-14  N5_1-15  N5_1-16  N5_1-17
A0A075B6H9 6.583680 6.480194 5.489319 5.905465 6.031421 6.583196 5.460192
A0A075B6I0 6.563919 6.593046 6.226301 6.190450 6.068972 6.837802 6.001926
A0A075B6J9 4.220516       NA 6.295460 6.118923 3.961637 5.138979       NA
A0A075B6K2 5.174246 6.908876 5.369276 4.880584 4.530717 4.796846 4.109406
A0A075B6K4 6.026022 6.281561 5.839536 5.956612 5.561913 6.304267 5.692557
A0A075B6K5 6.510111 8.043830 6.319683 5.772054 5.756860 6.596928 5.634524
            N5_1-18  N5_1-19  N5_1-20  N5_1-21  N5_1-22   N5_2-11   N5_2-12
A0A075B6H9 5.564293 5.251385 5.728160 5.103266 5.454972 10.970818 10.420435
A0A075B6I0 5.761484 5.538847 6.138815 5.392964 5.586169 10.985817 10.724596
A0A075B6J9 4.351910       NA 3.346526 3.868490 4.452400  7.538050  7.870644
A0A075B6K2 4.118724 3.936249 4.816290 4.103849 4.482101  9.134534  8.807921
A0A075B6K4 5.186385 5.244871 5.646386 5.240059 5.349715  9.823665  9.521680
A0A075B6K5 5.292597 5.177321 5.951054 5.279637 5.152645 10.151324 10.386372
            N5_2-13   N5_2-14  N5_2-15  N5_2-16  N5_2-17   N5_2-18   N5_2-19
A0A075B6H9 9.807995  9.963596 9.015058 9.427895 11.00459 10.073346 11.288053
A0A075B6I0 9.836235 10.202927 9.319540 9.518559 11.26081 10.276327 11.633188
A0A075B6J9 7.527959  7.640580 7.063350 6.614966  8.38656  7.443369  8.915308
A0A075B6K2 8.350864  9.148763 9.080467 9.447667 10.73987 10.003650 10.608060
A0A075B6K4 9.098888  9.251665 8.537700 8.810335 10.56926  9.737755 10.630409
A0A075B6K5 9.693752  9.802752 9.571768 9.717627 11.28293 10.391365 11.373876
             N5_2-20   N5_2-21  N5_2-22  P1_1-20  P1_1-21  P1_1-22  P1_2-20
A0A075B6H9 11.528784 10.161948 8.669654 3.216914 3.125185 5.081189 6.863663
A0A075B6I0 11.563916 10.407457 9.101878       NA 5.969081 6.099205 6.648957
A0A075B6J9  8.815819  6.989196 6.531530 6.044071       NA       NA 4.468924
A0A075B6K2 10.215501  8.975762 7.327773       NA       NA       NA       NA
A0A075B6K4 10.663973  9.650372 8.618700       NA       NA 5.107145 5.929575
A0A075B6K5 11.467047 10.208362 8.795006 4.065803 3.951106 5.146014 5.611323
            P1_2-21  P1_2-22  P1_1-11  P1_1-12  P1_1-13  P1_1-14  P1_1-15
A0A075B6H9 7.260071 7.472674 5.849974 5.221125 4.434250 6.002475 5.036578
A0A075B6I0 7.869865 8.167937 5.973658 5.755787 5.457838 6.293927 5.528780
A0A075B6J9 5.561093 5.200155 3.462954 3.977813 6.391362 5.626575       NA
A0A075B6K2       NA       NA 2.609326       NA       NA       NA       NA
A0A075B6K4 6.927945 7.200317 5.181778 5.097870 4.891733 5.327649 4.521223
A0A075B6K5 6.388574 6.660398 4.294836 4.268274 3.014495 5.172935 2.999166
            P1_1-16  P1_1-17  P1_1-18  P1_1-19  P1_2-11  P1_2-12  P1_2-13
A0A075B6H9 4.668430 4.697290 4.715434 5.404396 7.925528 7.163652 7.226422
A0A075B6I0 5.436456 5.619717 5.511009 5.749251 7.787679 7.475036 7.133044
A0A075B6J9 5.627385       NA 5.149557       NA 5.374171 6.518513 3.812680
A0A075B6K2 3.640308       NA       NA 2.564755 5.387631 4.171529 4.596102
A0A075B6K4 5.077098 4.642101 4.951409 4.990210 6.811293 6.501802 6.239267
A0A075B6K5 3.506232 3.568188 4.206957 4.215349 7.011010 6.724286 6.473199
            P1_2-14  P1_2-15  P1_2-16  P1_2-17  P1_2-18  P1_2-19  P3_1-11
A0A075B6H9 8.096953 7.217584 8.116657 7.034899 6.814093 7.631970 3.907203
A0A075B6I0 8.299625 7.437227 8.218208 7.417073 6.815224 7.428903 5.610291
A0A075B6J9       NA 5.278769 5.803638 5.532032 6.144029 4.740172       NA
A0A075B6K2 5.412568 4.734273 5.304828 3.789570       NA 5.130435       NA
A0A075B6K4 7.550622 6.793782 7.146890 6.723651 6.110218 6.849319 5.093162
A0A075B6K5 7.558216 6.372281 6.860586 6.354623 5.909067 6.794301 2.831573
            P3_1-12  P3_1-13  P3_1-14  P3_1-15  P3_1-16  P3_1-17  P3_1-18
A0A075B6H9       NA       NA 4.706185 5.398897 5.732552 6.576971 5.190468
A0A075B6I0 5.251255       NA 6.494669 7.013234 7.726040 7.624318 6.548446
A0A075B6J9       NA       NA       NA       NA       NA       NA 5.140375
A0A075B6K2       NA       NA       NA       NA       NA       NA       NA
A0A075B6K4       NA 6.394572 4.652691 4.734922 5.378730 5.843353 4.719923
A0A075B6K5 2.702912 5.262025 4.509118 5.552568 5.160577 5.563522 4.174454
            P3_1-19  P3_1-20  P3_1-21  P3_1-22  P3_2-11  P3_2-12  P3_2-13
A0A075B6H9 5.421266 4.567784 7.001915 5.469018 8.115290 8.471480 8.008134
A0A075B6I0 6.769862 6.359935 8.016583 6.890002 9.200646 9.625762 9.614069
A0A075B6J9 5.597255       NA 3.564184       NA 5.519635 6.015570 5.338975
A0A075B6K2       NA       NA       NA       NA       NA       NA       NA
A0A075B6K4 5.223789 4.595162 6.298715 4.781303 6.601516 7.223985 6.958841
A0A075B6K5 4.599284 3.733936 5.985698 5.197628 7.238871 7.892514 8.063943
            P3_2-14  P3_2-15  P3_2-16  P3_2-17  P3_2-18  P3_2-19  P3_2-20
A0A075B6H9 8.269179 8.114472 8.080233 7.291883 7.777956 6.767301 7.602602
A0A075B6I0 9.723865 9.661421 9.311343 8.761093 9.128477       NA 8.641932
A0A075B6J9 4.931982 5.530205 5.316104       NA 5.040887       NA 7.197374
A0A075B6K2 6.303981 5.026825 5.487170 4.783668 5.718681       NA 5.868099
A0A075B6K4 6.933539 6.778157 6.764822 6.445373 6.802835 6.635723 5.804876
A0A075B6K5 7.980906 7.909380 7.373976 7.354662 7.574495 6.605376 7.372402
            P3_2-21  P3_2-22  P5_1-11  P5_1-12  P5_1-13  P5_1-14  P5_1-15
A0A075B6H9 8.374045 8.538098 7.673835 7.724646 7.487061 6.250399 7.165688
A0A075B6I0 9.415336 9.890781 8.896507 9.120331 8.616306 8.165530 8.904704
A0A075B6J9       NA       NA 8.166882 7.690558 7.168363 5.769654 5.770205
A0A075B6K2       NA 6.343834       NA 3.831118       NA       NA 3.307248
A0A075B6K4 7.003091 7.484914 6.857647 6.843582 6.774080 5.696066 6.489971
A0A075B6K5 7.581922 8.271451 6.486556 6.776268 6.469449 5.047813 5.689609
            P5_1-16 P5_1-17  P5_1-18  P5_1-19  P5_1-20  P5_1-21  P5_1-22
A0A075B6H9 7.406362      NA 7.024268 6.819202 7.710860 7.029694 7.940995
A0A075B6I0 9.044795      NA 9.320038 9.211952 8.767446 8.648101 9.171046
A0A075B6J9 6.169091      NA 5.997128 6.081724 6.858923 6.363346 7.758843
A0A075B6K2       NA      NA       NA       NA       NA       NA       NA
A0A075B6K4 6.822805      NA 6.251709 6.465172 6.576639 7.083514 7.157548
A0A075B6K5 5.934037      NA 6.057209 5.442152 5.565423 6.100928 6.935636
             P5_2-11  P5_2-12   P5_2-13   P5_2-14   P5_2-15   P5_2-16   P5_2-17
A0A075B6H9  9.716456 6.408468  9.354129  9.201845  9.947288  9.866094  8.681903
A0A075B6I0 11.365746 8.904470 11.094145 10.912334 11.501445 11.504517 10.838254
A0A075B6J9  8.803909 8.209107  8.104616  7.944657  8.402671  8.087613  8.702483
A0A075B6K2  6.206217       NA  6.106666  5.986506  6.102423  6.283411        NA
A0A075B6K4  9.043197 7.605595  8.899206  8.896077  9.589528  9.516744        NA
A0A075B6K5  9.031140 7.604054  9.022393  8.554160  8.943028  9.101952  8.613726
             P5_2-18   P5_2-19   P5_2-20   P5_2-21   P5_2-22
A0A075B6H9  9.765927  9.996353  8.897189  9.623958 10.281814
A0A075B6I0 11.012371 11.293644 10.397453 10.945902 11.798943
A0A075B6J9  9.582637  8.369209  7.689413  9.431461  9.497251
A0A075B6K2  5.306327  5.891270  4.977176  5.848726  6.288980
A0A075B6K4  8.703061  9.087552  7.931506  9.021279  9.528588
A0A075B6K5  8.318706  8.804549  7.575727  8.682084  9.044534
  • The imported feature matrix is stored in the slot named sample_features. Additionally, spverse calculates several additional features and appends them to this matrix, such as the number of identified proteins and the mean protein expression level for each spot.
head(local_sp@sample_features)
  samples individual    ts  num    means       cvs
1 N1_1-11         N1 tumor 6479 5.209566 0.2432002
2 N1_1-12         N1 tumor 6464 5.178775 0.2445205
3 N1_1-13         N1 tumor 6360 5.197567 0.2362508
4 N1_1-14         N1 tumor 6503 5.172129 0.2465583
5 N1_1-15         N1 tumor 6477 5.188717 0.2439340
6 N1_1-16         N1 tumor 6301 5.242122 0.2432640
  • The spverse package computes a set of statistical metrics for each protein, encompassing the count of samples where the protein was detected, along with the mean expression level and coefficient of variation of each protein.
head(local_sp@protein_features)
           num    samples    means       cvs
A0A075B6H9 140 A0A075B6H9 8.146981 0.3315710
A0A075B6I0 132 A0A075B6I0 8.170975 0.2442017
A0A075B6J9 109 A0A075B6J9 6.308350 0.2640950
A0A075B6K2  82 A0A075B6K2 5.979558 0.3398927
A0A075B6K4 138 A0A075B6K4 6.936107 0.2442652
A0A075B6K5 142 A0A075B6K5 6.767544 0.3094782

2.2 Global spatial proteomics reading

  • Global spatial proteomics data also includes the content of the two aforementioned files. The difference is that compared with local spatial proteomics data, global spatial proteomics data additionally contains location information, which is stored in an Excel file named “location” with the suffix “.xlsx”.

  • If your samples are derived from multiple individuals, the spatial location information of spots from different individuals is stored in separate worksheets, each named after the corresponding sample. As shown in Table 3, each worksheet contains the positional relationships between different spots.

Table 3
sample5 sample11 sample17 sample22
sample1 sample6 sample12 sample18 sample23 sample28
sample2 sample7 sample13 sample19 sample24 sample29
sample3 sample8 sample14 sample25 sample30
sample4 sample9 sample15 sample20 sample26
sample10 sample16 sample21 sample27
  • As with reading local spatial proteomics data previously, the three aforementioned files must be stored in the same folder.
global_sp <- creatsp("D:/Rdata/zhc/article/part2/fan/s966_section",filetype = "xls")

print(global_sp)
sp data with 599 samples for 7748 features
  • The imported location information is integrated into coordinate data, which corresponds to the “x” and “y” columns in the sample_features slot of the sp object.
head(global_sp@sample_features)
   samples  y x individual  num    means       cvs
1     N1_1 10 1         N1 6222 5.879781 0.2135285
13    N1_2 10 2         N1 6359 5.746185 0.2229226
24    N1_3 10 3         N1 6614 5.694115 0.2282357
35    N1_4 10 4         N1 6494 5.705090 0.2264438
46    N1_5 10 5         N1 6368 5.759014 0.2226164
57    N1_6 10 6         N1 6329 5.812312 0.2197434