Example of using Python and R in a single notebook

Using Multiple Kernels in one notebook

Multiple kernels can be used in a single a SoS notebook, with the SoS kernel being the super kernel that manages others. You can select kernel of a code cell using the language selection dropdown box at the top right corner or using SoS magics. Prompt areas of code cells belonging to different kernels are marked by different colors. You however might not be able to see the language dropdown box and colors as shown below if you are viewing the notebook with a viewer that does not recognize SoS kernel inormation.

image.png

An example of using Python and R in the same notebook

In this example we are converting an MS Excel file to csv format using Python pandas module. We then use R to annotate the gene names and draw some plot. The annotated data will be sent back to Python and write in excel format.

Let us first have a look at the data in SoS using its %preview magic. This magic reads data from the excel file and previews it as a sortable and searchable table. The -n option tells the magic to display the result in the main notebook, not in the SoS side panel.

In [1]:
%preview DEG_list.xlsx
> DEG_list.xlsx (107.4 KiB):
Only the first 200 of the 1184 records are previewed. Use option --limit to set a new limit.

  ensembl_gene_id   baseMean   log2FoldChange   stat   pvalue   padj  
0 ENSMUSG00000042816 1686.121821 3.390100 -28.589868 8.979679e-180 7.696034e-176
1 ENSMUSG00000031635 358.401785 3.614133 -21.471980 2.846325e-102 8.131476e-99
2 ENSMUSG00000020838 551.448621 2.532469 -18.878942 1.699551e-79 2.913201e-76
3 ENSMUSG00000021765 597.716318 2.265537 -17.571072 4.103412e-69 5.024042e-66
4 ENSMUSG00000027907 3236.448003 1.306965 -15.152852 7.254873e-52 6.908654e-49
5 ENSMUSG00000026247 744.567819 1.999957 -14.202403 8.852428e-46 6.897249e-43
6 ENSMUSG00000030272 3322.013499 1.029098 -13.056674 5.821582e-39 3.837990e-36
7 ENSMUSG00000069793 317.952685 1.645894 -12.727226 4.174068e-37 2.384924e-34
8 ENSMUSG00000028494 4659.305199 1.051199 -12.102120 1.029183e-33 5.188595e-31
9 ENSMUSG00000059645 107.043454 1.777720 -11.629145 2.930187e-31 1.287855e-28
10 ENSMUSG00000026834 184.146231 1.576185 -10.924823 8.771122e-28 3.496414e-25
11 ENSMUSG00000069355 78.423674 1.896248 -10.639715 1.947240e-26 7.101625e-24
12 ENSMUSG00000024066 1207.689222 1.287185 -10.412868 2.165954e-25 7.279729e-23
13 ENSMUSG00000059173 2047.297734 1.290401 -10.363868 3.620191e-25 1.128249e-22
14 ENSMUSG00000044626 107.545685 1.479431 -9.920675 3.384591e-23 9.833097e-21
15 ENSMUSG00000029552 990.570372 0.942947 -9.652480 4.798095e-22 1.305463e-19
16 ENSMUSG00000000278 2246.095680 0.820046 -9.477766 2.597862e-21 6.646262e-19
17 ENSMUSG00000023067 3740.729262 0.935633 -9.180521 4.290090e-20 1.035725e-17
18 ENSMUSG00000021843 8362.210457 0.774680 -8.942443 3.806602e-19 8.699862e-17
19 ENSMUSG00000044258 622.236008 1.062715 -8.723723 2.692001e-18 5.840961e-16
20 ENSMUSG00000020205 1313.876243 1.029466 -8.587091 8.919931e-18 1.842127e-15
21 ENSMUSG00000037280 336.544531 1.119365 -8.342550 7.270520e-17 1.432460e-14
22 ENSMUSG00000027556 365.075577 1.161261 -8.021451 1.045036e-15 1.968457e-13
23 ENSMUSG00000031799 7421.027362 0.624473 -7.913186 2.508835e-15 4.526730e-13
24 ENSMUSG00000036905 1706.843435 0.709253 -7.846027 4.294230e-15 7.435091e-13
25 ENSMUSG00000044667 545.471721 0.867126 -7.784684 6.988793e-15 1.163057e-12
26 ENSMUSG00000021125 389.752252 0.884616 -7.713982 1.219520e-14 1.953626e-12
27 ENSMUSG00000025351 5138.213127 0.601866 -7.593747 3.107838e-14 4.799230e-12
28 ENSMUSG00000032666 5242.276743 0.592958 -7.454353 9.030998e-14 1.346090e-11
29 ENSMUSG00000019866 554.456799 0.850782 -7.439136 1.013460e-13 1.459809e-11
30 ENSMUSG00000025608 1575.642204 0.686405 -7.364919 1.772542e-13 2.470174e-11
31 ENSMUSG00000043336 572.398895 0.802930 -7.234809 4.661851e-13 6.292031e-11
32 ENSMUSG00000037940 265.079339 0.911853 -7.210731 5.565229e-13 7.312611e-11
33 ENSMUSG00000039364 194.167058 0.998772 -6.998846 2.580798e-12 3.276849e-10
34 ENSMUSG00000056749 345.920854 0.914688 -6.969709 3.175962e-12 3.916486e-10
35 ENSMUSG00000032802 17749.447535 0.598266 -6.892196 5.493748e-12 6.585198e-10
36 ENSMUSG00000024672 211.819493 0.887656 -6.825385 8.769012e-12 1.022515e-09
37 ENSMUSG00000010086 4098.481132 -0.572777 6.720270 1.813879e-11 2.059053e-09
38 ENSMUSG00000058665 29.247691 0.967621 -6.683662 2.330438e-11 2.577164e-09
39 ENSMUSG00000009596 58.610232 0.944848 -6.642619 3.081587e-11 3.301343e-09
40 ENSMUSG00000029306 515.056424 0.913920 -6.578546 4.750698e-11 4.965348e-09
41 ENSMUSG00000028525 1397.491979 0.579037 -6.531912 6.493551e-11 6.625354e-09
42 ENSMUSG00000044060 2919.794150 0.634026 -6.424378 1.324101e-10 1.319559e-08
43 ENSMUSG00000021871 1033.326078 0.621687 -6.372998 1.853679e-10 1.805336e-08
44 ENSMUSG00000026670 4392.649088 0.461576 -6.338069 2.326619e-10 2.215588e-08
45 ENSMUSG00000025723 3256.551545 -0.668514 6.308321 2.820793e-10 2.627783e-08
46 ENSMUSG00000058715 556.298426 0.735078 -6.194826 5.834941e-10 5.320039e-08
47 ENSMUSG00000000214 4138.211600 -0.610492 6.070828 1.272524e-09 1.136059e-07
48 ENSMUSG00000021411 477.330006 0.732723 -6.026429 1.676222e-09 1.465924e-07
49 ENSMUSG00000051209 145.343991 0.822896 -5.958867 2.539931e-09 2.176848e-07
50 ENSMUSG00000046223 471.768674 0.710971 -5.915084 3.317058e-09 2.787141e-07
51 ENSMUSG00000021996 6915.461113 0.554238 -5.878588 4.137815e-09 3.394226e-07
52 ENSMUSG00000022582 88.869956 0.845882 -5.836138 5.342459e-09 4.319579e-07
53 ENSMUSG00000075225 187.970746 0.762592 -5.775902 7.654194e-09 6.046108e-07
54 ENSMUSG00000039910 898.929113 0.706779 -5.760166 8.403126e-09 6.517556e-07
55 ENSMUSG00000025348 8836.099402 0.687449 -5.706812 1.151120e-08 8.769487e-07
56 ENSMUSG00000028145 2209.860304 0.477298 -5.685315 1.305714e-08 9.773471e-07
57 ENSMUSG00000024743 12173.281232 -0.480565 5.650580 1.599070e-08 1.176380e-06
58 ENSMUSG00000050315 661.302294 0.782864 -5.630019 1.801894e-08 1.303218e-06
59 ENSMUSG00000021565 1407.135648 0.641439 -5.608616 2.039504e-08 1.450587e-06
60 ENSMUSG00000053477 3221.484564 0.476041 -5.551818 2.827136e-08 1.977956e-06
61 ENSMUSG00000007613 1878.831124 0.555008 -5.511270 3.562528e-08 2.452195e-06
62 ENSMUSG00000003872 498.277117 -0.614792 5.487667 4.072760e-08 2.759335e-06
63 ENSMUSG00000060002 3216.792835 0.613103 -5.473168 4.420617e-08 2.952715e-06
64 ENSMUSG00000030399 1621.263042 0.200993 -5.436427 5.435973e-08 3.556413e-06
65 ENSMUSG00000045954 1547.190653 0.602709 -5.420474 5.944109e-08 3.844829e-06
66 ENSMUSG00000050730 1914.008502 0.490603 -5.411401 6.253366e-08 3.990567e-06
67 ENSMUSG00000024621 2058.520289 0.561670 -5.392116 6.963283e-08 4.356118e-06
68 ENSMUSG00000037348 2683.166398 -0.453835 5.374706 7.670781e-08 4.746746e-06
69 ENSMUSG00000040552 416.790372 0.638669 -5.351247 8.735010e-08 5.328356e-06
70 ENSMUSG00000020326 8930.360647 0.487337 -5.334489 9.581412e-08 5.762631e-06
71 ENSMUSG00000038151 69.583461 0.782195 -5.311110 1.089594e-07 6.440249e-06
72 ENSMUSG00000036062 74983.323382 -0.453463 5.290473 1.220002e-07 7.112942e-06
73 ENSMUSG00000020732 2187.919687 -0.428484 5.278700 1.301033e-07 7.483561e-06
74 ENSMUSG00000063889 640.069865 0.586185 -5.270856 1.357893e-07 7.715518e-06
75 ENSMUSG00000018845 111.480390 0.708201 -5.246122 1.553341e-07 8.701247e-06
76 ENSMUSG00000020099 464.164167 -0.602612 5.210926 1.879007e-07 1.038969e-05
77 ENSMUSG00000025318 6202.137797 -0.541901 5.195926 2.037029e-07 1.111997e-05
78 ENSMUSG00000026778 5643.562480 -0.371148 5.163726 2.420823e-07 1.304885e-05
79 ENSMUSG00000026674 3577.461644 0.561261 -5.144960 2.675772e-07 1.424392e-05
80 ENSMUSG00000040990 1922.697737 0.425620 -5.124828 2.978093e-07 1.565874e-05
81 ENSMUSG00000042826 1061.179181 0.541590 -5.111255 3.200253e-07 1.662289e-05
82 ENSMUSG00000041481 4975.589229 -0.422457 5.097114 3.448701e-07 1.769886e-05
83 ENSMUSG00000022902 17.415075 0.569847 -5.073514 3.905364e-07 1.974686e-05
84 ENSMUSG00000020798 54.631755 0.727070 -5.057038 4.258182e-07 2.134196e-05
85 ENSMUSG00000028072 7499.283874 -0.545480 5.040457 4.644211e-07 2.300764e-05
86 ENSMUSG00000025592 65.433682 0.740815 -5.026139 5.004525e-07 2.450930e-05
87 ENSMUSG00000022836 1330.233343 0.623212 -5.016758 5.255078e-07 2.544556e-05
88 ENSMUSG00000005045 3628.388469 -0.426177 4.997166 5.817912e-07 2.779091e-05
89 ENSMUSG00000025090 608.762834 0.543096 -4.988483 6.085519e-07 2.881544e-05
90 ENSMUSG00000000416 1155.098102 0.542034 -4.956080 7.192943e-07 3.368695e-05
91 ENSMUSG00000062760 4008.249143 -0.416101 4.928459 8.288085e-07 3.839624e-05
92 ENSMUSG00000033983 902.301269 0.462619 -4.924519 8.456817e-07 3.875890e-05
93 ENSMUSG00000020427 1337.503405 0.604765 -4.910723 9.074128e-07 4.114805e-05
94 ENSMUSG00000020737 6621.883776 0.416878 -4.885709 1.030572e-06 4.624356e-05
95 ENSMUSG00000037062 6076.458447 0.420008 -4.881184 1.054506e-06 4.682715e-05
96 ENSMUSG00000031382 45.167336 0.406106 -4.867451 1.130467e-06 4.968546e-05
97 ENSMUSG00000035576 464.441725 -0.592566 4.849521 1.237598e-06 5.384179e-05
98 ENSMUSG00000001349 148.230383 0.660789 -4.841966 1.285610e-06 5.536844e-05
99 ENSMUSG00000053063 392.418630 0.679222 -4.825189 1.398703e-06 5.978657e-05
100 ENSMUSG00000004609 275.760166 0.673551 -4.811205 1.500234e-06 6.333868e-05
101 ENSMUSG00000024873 562.289469 -0.581251 4.794897 1.627581e-06 6.804478e-05
102 ENSMUSG00000075511 1418.494601 -0.454450 4.775298 1.794410e-06 7.429463e-05
103 ENSMUSG00000004031 2248.642201 -0.398909 4.753532 1.998932e-06 8.197055e-05
104 ENSMUSG00000028459 150.698103 0.666142 -4.738651 2.151452e-06 8.738872e-05
105 ENSMUSG00000031519 65.708107 0.492228 -4.719913 2.359458e-06 9.493774e-05
106 ENSMUSG00000019966 4772.631620 0.423625 -4.709819 2.479374e-06 9.883477e-05
107 ENSMUSG00000040612 1708.813914 0.604766 -4.693462 2.686198e-06 1.060924e-04
108 ENSMUSG00000000682 484.846830 0.626666 -4.680273 2.864929e-06 1.121181e-04
109 ENSMUSG00000041653 935.219188 -0.606189 4.674512 2.946540e-06 1.144430e-04
110 ENSMUSG00000052921 484.158457 0.536571 -4.646985 3.368215e-06 1.294497e-04
111 ENSMUSG00000033350 4599.085909 0.551091 -4.635570 3.559546e-06 1.355870e-04
112 ENSMUSG00000078771 182.455994 0.620041 -4.625054 3.745010e-06 1.413947e-04
113 ENSMUSG00000030731 1060.826544 -0.542463 4.611812 3.991747e-06 1.493942e-04
114 ENSMUSG00000057897 2165.501453 -0.393365 4.603239 4.159713e-06 1.543325e-04
115 ENSMUSG00000021376 636.677868 0.560542 -4.578840 4.675618e-06 1.712495e-04
116 ENSMUSG00000015484 140.888497 0.673017 -4.571208 4.849216e-06 1.768519e-04
117 ENSMUSG00000024256 6083.247354 0.487655 -4.557837 5.168315e-06 1.868989e-04
118 ENSMUSG00000040724 6615.498840 -0.317752 4.521351 6.144612e-06 2.203447e-04
119 ENSMUSG00000039546 56.647051 0.667581 -4.508363 6.532977e-06 2.327259e-04
120 ENSMUSG00000029201 1776.636541 0.388157 -4.494057 6.987887e-06 2.464596e-04
121 ENSMUSG00000005220 118.438206 0.640279 -4.483429 7.345319e-06 2.569513e-04
122 ENSMUSG00000020458 53205.000765 0.377116 -4.476709 7.580255e-06 2.630226e-04
123 ENSMUSG00000048096 130.140644 0.657768 -4.470087 7.818788e-06 2.691202e-04
124 ENSMUSG00000075249 23.933902 0.529569 -4.458699 8.245873e-06 2.815588e-04
125 ENSMUSG00000062997 5890.793347 0.390708 -4.449010 8.626681e-06 2.922331e-04
126 ENSMUSG00000082329 27.549398 -0.316849 4.429224 9.457291e-06 3.178577e-04
127 ENSMUSG00000066477 457.333336 -0.552386 4.413249 1.018310e-05 3.389291e-04
128 ENSMUSG00000027800 1352.981210 0.480121 -4.400013 1.082442e-05 3.574201e-04
129 ENSMUSG00000058070 20208.608139 -0.378708 4.392670 1.119671e-05 3.669653e-04
130 ENSMUSG00000026880 2706.839047 0.449022 -4.373607 1.222106e-05 3.967446e-04
131 ENSMUSG00000025321 10607.677389 0.431241 -4.361491 1.291788e-05 4.169970e-04
132 ENSMUSG00000075270 2926.923451 -0.408322 4.352885 1.343575e-05 4.304715e-04
133 ENSMUSG00000058546 4217.501963 0.452739 -4.343360 1.403199e-05 4.462381e-04
134 ENSMUSG00000024349 492.890523 0.468243 -4.333088 1.470324e-05 4.641402e-04
135 ENSMUSG00000032036 1545.213929 -0.412749 4.328413 1.501878e-05 4.704466e-04
136 ENSMUSG00000027313 280.148989 0.573529 -4.324163 1.531123e-05 4.744788e-04
137 ENSMUSG00000032249 4214.430836 0.356434 -4.319295 1.565285e-05 4.834333e-04
138 ENSMUSG00000002012 450.459400 -0.491098 4.310303 1.630308e-05 4.999127e-04
139 ENSMUSG00000043832 150.109531 0.609018 -4.307250 1.652967e-05 5.032594e-04
140 ENSMUSG00000027208 523.843600 0.519336 -4.297960 1.723771e-05 5.211139e-04
141 ENSMUSG00000048899 6744.401771 -0.349289 4.291974 1.770918e-05 5.316166e-04
142 ENSMUSG00000049037 155.677742 0.608852 -4.286058 1.818718e-05 5.427030e-04
143 ENSMUSG00000094797 18.370489 0.358503 -4.275262 1.909123e-05 5.651862e-04
144 ENSMUSG00000021508 142.253613 0.629162 -4.268241 1.970204e-05 5.801245e-04
145 ENSMUSG00000059810 3919.962308 -0.365216 4.259339 2.050325e-05 5.985518e-04
146 ENSMUSG00000024789 1955.949602 0.381019 -4.251012 2.128072e-05 6.172130e-04
147 ENSMUSG00000032908 6283.349406 -0.377863 4.243526 2.200346e-05 6.338846e-04
148 ENSMUSG00000032269 5359.788720 -0.545080 4.224672 2.392889e-05 6.847497e-04
149 ENSMUSG00000043795 94.737661 0.612872 -4.213025 2.519727e-05 7.150769e-04
150 ENSMUSG00000058600 4786.732120 0.347805 -4.204510 2.616484e-05 7.376506e-04
151 ENSMUSG00000054277 3590.835421 -0.344597 4.197494 2.698853e-05 7.556487e-04
152 ENSMUSG00000062933 384.082182 -0.592479 4.191350 2.772993e-05 7.716213e-04
153 ENSMUSG00000035861 22.762075 0.528728 -4.181275 2.898784e-05 8.014202e-04
154 ENSMUSG00000036144 704.558374 0.482705 -4.176654 2.958290e-05 8.126290e-04
155 ENSMUSG00000082145 18.081713 -0.315132 4.173833 2.995175e-05 8.175207e-04
156 ENSMUSG00000026768 134.869847 0.609512 -4.163156 3.138793e-05 8.512984e-04
157 ENSMUSG00000005667 1392.797019 0.406644 -4.156987 3.224728e-05 8.677404e-04
158 ENSMUSG00000042895 26.892136 0.283982 -4.151201 3.307356e-05 8.858029e-04
159 ENSMUSG00000002908 1882.511166 -0.429813 4.138458 3.496486e-05 9.292971e-04
160 ENSMUSG00000026484 1079.820043 0.433964 -4.133742 3.569035e-05 9.440869e-04
161 ENSMUSG00000078453 407.984339 0.498521 -4.127025 3.674860e-05 9.661163e-04
162 ENSMUSG00000031962 393.447395 -0.482314 4.101942 4.096965e-05 1.070519e-03
163 ENSMUSG00000083863 82.380427 0.606053 -4.093140 4.255705e-05 1.104757e-03
164 ENSMUSG00000032925 1548.604347 0.482915 -4.089063 4.331188e-05 1.118086e-03
165 ENSMUSG00000074207 369.574207 0.524188 -4.078387 4.534922e-05 1.163669e-03
166 ENSMUSG00000026435 1479.800973 -0.408509 4.071521 4.670711e-05 1.191379e-03
167 ENSMUSG00000022217 2659.845733 -0.437365 4.067594 4.750108e-05 1.204462e-03
168 ENSMUSG00000015536 3903.413565 0.351420 -4.061839 4.868759e-05 1.227285e-03
169 ENSMUSG00000026981 67.297339 0.596874 -4.052241 5.072928e-05 1.272811e-03
170 ENSMUSG00000085905 38.615920 0.574895 -4.043564 5.264488e-05 1.311607e-03
171 ENSMUSG00000031245 279.135564 0.568970 -4.040085 5.343192e-05 1.321611e-03
172 ENSMUSG00000032253 3612.102225 0.430972 -4.031820 5.534660e-05 1.363069e-03
173 ENSMUSG00000025867 13926.271701 -0.334032 4.028300 5.618151e-05 1.375725e-03
174 ENSMUSG00000068798 2640.796289 0.419686 -4.020269 5.813161e-05 1.415389e-03
175 ENSMUSG00000025290 12628.526847 0.371852 -4.011613 6.030528e-05 1.460018e-03
176 ENSMUSG00000094335 20.686622 0.426406 -4.003223 6.248541e-05 1.504301e-03
177 ENSMUSG00000045318 775.498537 -0.496834 4.000499 6.320902e-05 1.517205e-03
178 ENSMUSG00000096931 35.233861 0.535329 -3.994924 6.471497e-05 1.540666e-03
179 ENSMUSG00000022895 1134.245840 0.410693 -3.987475 6.678019e-05 1.581049e-03
180 ENSMUSG00000045246 509.419290 -0.491459 3.980554 6.875477e-05 1.618854e-03
181 ENSMUSG00000023911 370.424747 -0.492521 3.972239 7.120036e-05 1.667275e-03
182 ENSMUSG00000030772 6967.211749 -0.324692 3.955762 7.629094e-05 1.773005e-03
183 ENSMUSG00000033306 2060.455679 0.389209 -3.951667 7.760864e-05 1.797689e-03
184 ENSMUSG00000031958 703.556060 -0.411147 3.941892 8.084140e-05 1.862503e-03
185 ENSMUSG00000049404 1872.396770 -0.387567 3.936694 8.261182e-05 1.893114e-03
186 ENSMUSG00000043154 1969.194245 0.329759 -3.929912 8.497691e-05 1.934887e-03
187 ENSMUSG00000030357 17250.957141 -0.284794 3.909251 9.258278e-05 2.099155e-03
188 ENSMUSG00000062078 11057.268805 0.433507 -3.900608 9.595139e-05 2.161239e-03
189 ENSMUSG00000018774 332.882443 0.506687 -3.891611 9.958079e-05 2.234181e-03
190 ENSMUSG00000022215 18.180890 0.263239 -3.879550 1.046500e-04 2.333293e-03
191 ENSMUSG00000075277 254.185811 -0.483543 3.874812 1.067069e-04 2.369253e-03
192 ENSMUSG00000006411 969.972500 -0.377833 3.865833 1.107106e-04 2.445477e-03
193 ENSMUSG00000060212 2673.217124 -0.394651 3.857940 1.143467e-04 2.512843e-03
194 ENSMUSG00000075602 974.623857 0.413818 -3.848100 1.190377e-04 2.602582e-03
195 ENSMUSG00000026305 1492.203785 0.350318 -3.843718 1.211842e-04 2.632723e-03
196 ENSMUSG00000021710 782.053114 0.371730 -3.840828 1.226199e-04 2.653823e-03
197 ENSMUSG00000026959 3255.882216 -0.388816 3.834714 1.257103e-04 2.707035e-03
198 ENSMUSG00000027997 313.742234 0.485476 -3.829868 1.282120e-04 2.748783e-03
199 ENSMUSG00000027347 11487.058826 -0.328126 3.824952 1.307974e-04 2.785091e-03

Because SoS is based on Python 3.6, we can technically use SoS kernel to read the excel file, but we use a Python 3 kernel anyway:

In [2]:

We can then go to a R kernel and get data from the Python3 kernel

In [3]:

and use the ensembl library from bioconductor to get gene names from the Ensembl names in the data. The %preview magic previews the R variable.

In [4]:
Warning message:
                                                                      
%preview annotated
> annotated:
ensembl_gene_idbaseMeanlog2FoldChangestatpvaluepadjexternal_gene_name
ENSMUSG00000000214 4138.211600 -0.6104918 6.070828 1.272524e-09 1.136059e-07 Th
ENSMUSG00000000278 2246.095680 0.8200463 -9.477766 2.597862e-21 6.646262e-19 Scpep1
ENSMUSG00000000308 9818.688762 -0.2338556 2.821715 4.776759e-03 3.975285e-02 Ckmt1
ENSMUSG00000000320 155.787128 0.2876111 -1.986710 4.695454e-02 1.806179e-01 Alox12
ENSMUSG00000000416 1155.098102 0.5420341 -4.956080 7.192943e-07 3.368695e-05 Cttnbp2
ENSMUSG00000000420 3554.753276 0.2553115 -3.232391 1.227588e-03 1.514909e-02 Galnt1
ENSMUSG00000000627 4476.218886 0.2718751 -2.310253 2.087415e-02 1.067084e-01 Sema4f
ENSMUSG00000000628 319.764340 0.4280945 -2.946737 3.211462e-03 2.997037e-02 Hk2
ENSMUSG00000000682 484.846830 0.6266664 -4.680273 2.864929e-06 1.121181e-04 Cd52
ENSMUSG00000000730 7.627173 0.2362571 -2.682550 7.306328e-03 NA Dnmt3l
ENSMUSG00000000743 4563.611985 -0.2508448 2.641865 8.245084e-03 5.726458e-02 Chmp1a
ENSMUSG00000000751 3874.653413 -0.2331316 2.954892 3.127784e-03 2.945788e-02 Rpa1
ENSMUSG00000000794 77.932213 -0.2945470 2.003576 4.511548e-02 1.763317e-01 Kcnn3
ENSMUSG0000000102517006.747340 -0.2574028 2.833605 4.602618e-03 3.874925e-02 S100a6
ENSMUSG00000001280 2383.288580 0.2246021 -2.467233 1.361619e-02 8.035354e-02 Sp1
ENSMUSG00000001333 1162.464914 -0.2255600 2.420478 1.550010e-02 8.749375e-02 Sync
ENSMUSG00000001349 148.230383 0.6607889 -4.841966 1.285610e-06 5.536844e-05 Cnn1
ENSMUSG00000001380 7918.922528 0.1824277 -2.565276 1.030939e-02 6.648355e-02 Hars
ENSMUSG00000001415 4248.668568 -0.2422268 2.539732 1.109373e-02 6.998002e-02 Smg5
ENSMUSG00000001436 1263.258383 -0.2358637 2.236040 2.534914e-02 1.219163e-01 Slc19a1
ENSMUSG00000001700 311.687287 0.3393851 -2.773708 5.542144e-03 4.412350e-02 Gramd3
ENSMUSG00000001755 1499.568213 -0.2106140 2.275383 2.288294e-02 1.134287e-01 Coasy
ENSMUSG00000001774 4364.573704 0.2430831 -2.494867 1.260045e-02 7.610440e-02 Chordc1
ENSMUSG0000000184712823.805954 0.1778602 -2.162103 3.061020e-02 1.377861e-01 Rac1
ENSMUSG00000001865 509.589410 0.4566291 -3.556262 3.761693e-04 6.278402e-03 Cpa3
ENSMUSG00000001870 762.307906 0.3557346 -3.267733 1.084126e-03 1.391985e-02 Ltbp1
ENSMUSG00000001909 1565.248475 -0.2889704 3.250489 1.152069e-03 1.453099e-02 Trmt1
ENSMUSG00000001911 1633.174086 0.2427731 -2.141406 3.224132e-02 1.423618e-01 Nfix
ENSMUSG0000000192424575.966751 -0.2108731 2.320610 2.030790e-02 1.048171e-01 Uba1
ENSMUSG00000001964 1547.844892 0.1863153 -2.199904 2.781371e-02 1.294123e-01 Emd
ENSMUSG00000094335 20.686622 0.42640562 -4.003223 6.248541e-05 0.0015043012 Igkv1-117
ENSMUSG00000094546 64.161416 0.07526115 -2.260089 2.381575e-02 0.1167772425 Ighv1-26
ENSMUSG00000094626 22.445892 0.27654076 -2.095705 3.610832e-02 0.1530875042 Tmem121b
ENSMUSG00000094732 3.633133 0.14851581 -3.182034 1.462445e-03 NA 1500015L24Rik
ENSMUSG00000094797 18.370489 0.35850328 -4.275262 1.909123e-05 0.0005651862 Igkv6-15
ENSMUSG00000095028 17.748802 0.22071387 -1.964435 4.947964e-02 0.1864842910 Sirpb1b
ENSMUSG000000953621014.129481 0.33930276 -2.507800 1.214854e-02 0.0741588770 Gm14325
ENSMUSG00000095918 8.390640 0.23178587 -3.035931 2.397942e-03 NA Gm5861
ENSMUSG00000096403 29.135621 -0.24779867 3.079376 2.074344e-03 0.0222366002 Gm9825
ENSMUSG00000096459 14.669469 0.21227296 -2.909286 3.622557e-03 0.0327782193 Ighv9-3
ENSMUSG00000096490 51.152757 0.07584179 -3.109132 1.876381e-03 0.0207369783 Igkv10-94
ENSMUSG00000096715 16.382006 0.27253764 -3.301588 9.613918e-04 0.0128043637 Igkv3-4
ENSMUSG00000096780 124.903362 -0.34382425 2.328241 1.989932e-02 0.1034559469 Tmem181b-ps
ENSMUSG000000968472633.169634 -0.42194215 3.709991 2.072666e-04 0.0039562996 Tmem151b
ENSMUSG00000096931 35.233861 0.53532942 -3.994924 6.471497e-05 0.0015406656 Gm26656
ENSMUSG00000096965 2.868267 0.11022564 -2.252913 2.426467e-02 NA 3300005D01Rik
ENSMUSG00000097047 29.021538 0.30269031 -2.223309 2.619498e-02 0.1244824421 1110020A21Rik
ENSMUSG00000097180 53.448333 0.32390828 -2.222511 2.624878e-02 0.1245999453 2700038G22Rik
ENSMUSG00000097357 107.212979 0.40217004 -2.821819 4.775216e-03 0.0397528498 Gm16793
ENSMUSG00000097375 196.255308 0.37877733 -2.808336 4.979819e-03 0.0409592491 6720427I07Rik
ENSMUSG00000097404 101.130734 -0.31233829 2.122148 3.382527e-02 0.1464508726 Gm10814
ENSMUSG00000097466 145.564341 0.38068267 -2.630043 8.537396e-03 0.0584890902 D430036J16Rik
ENSMUSG00000097576 15.619078 0.25088628 -2.140711 3.229731e-02 0.1424989027 D930030I03Rik
ENSMUSG00000097622 63.268414 -0.47408131 3.199273 1.377745e-03 0.0165030907 A330033J07Rik
ENSMUSG00000097645 11.668458 0.20785568 -2.153071 3.131308e-02 NA Gm26863
ENSMUSG00000097908 219.536423 -0.28505132 2.258253 2.392987e-02 0.1171278958 4933404O12Rik
ENSMUSG00000098276 6.499809 0.22822696 -3.102306 1.920195e-03 NA Mir6358
ENSMUSG00000098318 16.721908 0.24041191 -2.126204 3.348625e-02 0.1454238144 Lockd
ENSMUSG00000098482 192.980606 0.35082491 -2.511948 1.200668e-02 0.0737129485 Mir6363
ENSMUSG000000989733337.553280 0.48588812 -3.340461 8.363935e-04 0.0114601289 Mir6236

We can also draw some plot and preview the result. Instead of displaying the result directly in the notebook, the R code saves the image in a file (so that it can be shared with others separately) and use the %preview magic to display it in the notebook.

In [5]:
pdf: 2
%preview result.png
> result.png (22.0 KiB):
No description has been provided for this image

After we confirm that the result is correct, we can transfer the data back to Python and write in excel format.

In [6]:

Session Info

As a good practice, a %sessioninfo magic should be used at the end of all SoS Notebooks to show the session information of all kernels involved.

In [7]:

SoS

SoS Version
0.16.12

Python3

Kernel
python3
Language
Python3
Version
3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:07:29) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
pandas
0.23.4

R

Kernel
ir
Language
R
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] biomaRt_2.34.2 feather_0.3.1 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18         pillar_1.3.0         compiler_3.4.2      
 [4] prettyunits_1.0.2    progress_1.2.0       bitops_1.0-6        
 [7] base64enc_0.1-3      tools_3.4.2          digest_0.6.15       
[10] uuid_0.1-2           bit_1.1-14           jsonlite_1.5        
[13] evaluate_0.11        RSQLite_2.1.1        memoise_1.1.0       
[16] tibble_1.4.2         pkgconfig_2.0.2      rlang_0.2.2         
[19] IRdisplay_0.5.0      DBI_1.0.0            curl_3.2            
[22] IRkernel_0.8.12.9000 parallel_3.4.2       httr_1.3.1          
[25] repr_0.15.0          stringr_1.3.1        S4Vectors_0.16.0    
[28] hms_0.4.2            IRanges_2.12.0       stats4_3.4.2        
[31] bit64_0.9-7          Biobase_2.38.0       R6_2.2.2            
[34] AnnotationDbi_1.40.0 XML_3.98-1.16        pbdZMQ_0.3-3        
[37] blob_1.1.1           magrittr_1.5         htmltools_0.3.6     
[40] BiocGenerics_0.24.0  assertthat_0.2.0     stringi_1.2.4       
[43] RCurl_1.95-4.11      crayon_1.3.4