forked from ComunidadBioInfo/cdsb2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-data-infrastructure-and-import.html
1822 lines (1579 loc) · 67.8 KB
/
02-data-infrastructure-and-import.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<title>Estructura e importe de datos</title>
<meta charset="utf-8" />
<meta name="author" content="Leonardo Collado-Torres" />
<meta name="date" content="2020-08-04" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-137796972-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137796972-1');
</script>
<link rel="stylesheet" href="xaringan-themer.css" type="text/css" />
</head>
<body>
<textarea id="source">
class: center, middle, inverse, title-slide
# <strong>Estructura e importe de datos</strong>
## <strong>Bioconductor</strong> para datos transcriptómicos de célula única (<strong>scRNA-seq</strong>) – <strong>CDSB2020</strong>
### <a href="http://lcolladotor.github.io/">Leonardo Collado-Torres</a>
### 2020-08-04
---
class: inverse
.center[
<a href="https://osca.bioconductor.org/"><img src="https://raw.githubusercontent.com/Bioconductor/OrchestratingSingleCellAnalysis-release/master/images/cover.png" style="width: 30%"/></a>
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
<a href='https://clustrmaps.com/site/1b5pl' title='Visit tracker'><img src='//clustrmaps.com/map_v2.png?cl=ffffff&w=150&t=n&d=rP3KLyAMuzVNcJFL-_C-B0XnLNVy8Sp6a8HDaKEnSzc'/></a>
]
.footnote[Descarga los materiales con `usethis::use_course('comunidadbioinfo/cdsb2020')` o revisalos en línea vía [**comunidadbioinfo.github.io/cdsb2020**](http://comunidadbioinfo.github.io/cdsb2020).]
<style type="text/css">
/* From https://github.com/yihui/xaringan/issues/147 */
.scroll-output {
height: 80%;
overflow-y: scroll;
}
/* https://stackoverflow.com/questions/50919104/horizontally-scrollable-output-on-xaringan-slides */
pre {
max-width: 100%;
overflow-x: scroll;
}
/* From https://github.com/yihui/xaringan/wiki/Font-Size */
.tiny{
font-size: 40%
}
/* From https://github.com/yihui/xaringan/wiki/Title-slide */
.title-slide {
background-image: url(https://raw.githubusercontent.com/Bioconductor/OrchestratingSingleCellAnalysis/master/images/Workflow.png);
background-size: 33%;
background-position: 0% 100%
}
</style>
---
# Diapositivas de Peter Hickey
Ve las diapositivas [aquí](https://docs.google.com/presentation/d/1X9qP3wNlnn3BMUQhuZwAo4vCV76c33X_M-UnHxkPZpE/edit)
---
# Código de R
.scroll-output[
```r
library('scRNAseq')
sce.416b <- LunSpikeInData(which = "416b")
```
```
## snapshotDate(): 2020-04-27
```
```
## see ?scRNAseq and browseVignettes('scRNAseq') for documentation
```
```
## loading from cache
```
```
## see ?scRNAseq and browseVignettes('scRNAseq') for documentation
```
```
## loading from cache
```
```
## see ?scRNAseq and browseVignettes('scRNAseq') for documentation
```
```
## loading from cache
```
```
## snapshotDate(): 2020-04-27
```
```
## loading from cache
```
```r
# Carga el paquete SingleCellExperiment
library('SingleCellExperiment')
# Extrae la matriz de cuentas del set de datos de 416b
counts.416b <- counts(sce.416b)
# Construye un nuevo SCE de la matriz de cuentas
sce <- SingleCellExperiment(assays = list(counts = counts.416b))
# Revisa el objeto que acabamos de crear
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(0):
## assays(1): counts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(0):
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(0):
## reducedDimNames(0):
## altExpNames(0):
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## Registered S3 method overwritten by 'pryr':
## method from
## print.bytes Rcpp
```
```
## 40.1 MB
```
```r
# Accesa la matriz de cuenta del compartimento (slot) "assays"
# OJO: ¡esto puede inundar tu sesión de R!
# 1. El método general
assay(sce, "counts")[1:6, 1:3]
```
```
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
```
```r
# 2. El método específico para accesar la matriz de cuentas "counts"
counts(sce)[1:6, 1:3]
```
```
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
```
```r
sce <- scater::logNormCounts(sce)
# Revisa el objeto que acabamos de actualizar
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(0):
## assays(2): counts logcounts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(0):
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(1): sizeFactor
## reducedDimNames(0):
## altExpNames(0):
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 112 MB
```
```r
# 1. El método general
assay(sce, "logcounts")[1:6, 1:3]
```
```
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
```
```r
# 2. El método específico para accesar la matriz de cuentas
# transformadas "logcounts"
logcounts(sce)[1:6, 1:3]
```
```
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1
## ENSMUSG00000102693 0
## ENSMUSG00000064842 0
## ENSMUSG00000051951 0
## ENSMUSG00000102851 0
## ENSMUSG00000103377 0
## ENSMUSG00000104017 0
```
```r
# Asigna una nueva matriz al compartimento (slot) de "assays"
assay(sce, "counts_100") <- assay(sce, "counts") + 100
# Enumera los "assays" en el objeto
assays(sce)
```
```
## List of length 3
## names(3): counts logcounts counts_100
```
```r
assayNames(sce)
```
```
## [1] "counts" "logcounts" "counts_100"
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 183 MB
```
```r
# Extrae la información de las muestras (metadata) del set de datos de 416b
colData.416b <- colData(sce.416b)
# Agrega algo de esa información a nuestro objeto de SCE
colData(sce) <- colData.416b[, c("phenotype", "block")]
# Revisa el objeto que acabamos de actualizar
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(0):
## assays(3): counts logcounts counts_100
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(0):
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(2): phenotype block
## reducedDimNames(0):
## altExpNames(0):
```
```r
# Accesa a la información de las muestras (metadata) en nuestro SCE
colData(sce)
```
```
## DataFrame with 192 rows and 2 columns
## phenotype
## <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 induced CBFB-MYH11 oncogene expression
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 induced CBFB-MYH11 oncogene expression
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 wild type phenotype
## block
## <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 20160113
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 20160113
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 20160113
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 20160113
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 20160113
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 20160325
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 20160325
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 20160325
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 20160325
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 20160325
```
```r
# Accesa una columna específica de la información de las muestras (metadata)
table(sce$block)
```
```
##
## 20160113 20160325
## 96 96
```
```r
# Ejemplo de una función que agrega columnas nuevas al colData
sce <- scater::addPerCellQC(sce.416b)
# Accesa a la información de las muestras (metadata) en nuestro SCE actualizado
colData(sce)
```
```
## DataFrame with 192 rows and 22 columns
## Source Name
## <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 SLX-9555.N701_S503.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 SLX-9555.N701_S504.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 SLX-9555.N701_S505.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 SLX-9555.N701_S506.C89V9ANXX.s_1.r_1
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## cell line cell type
## <character> <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 416B embryonic stem cell
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 416B embryonic stem cell
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 416B embryonic stem cell
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 416B embryonic stem cell
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 416B embryonic stem cell
## ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 416B embryonic stem cell
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 416B embryonic stem cell
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 416B embryonic stem cell
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 416B embryonic stem cell
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 416B embryonic stem cell
## single cell well quality
## <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 OK
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 OK
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 OK
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 OK
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 OK
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 OK
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 OK
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 OK
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 OK
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 OK
## genotype
## <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 Doxycycline-inducible CBFB-MYH11 oncogene
## phenotype
## <character>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 wild type phenotype
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 induced CBFB-MYH11 oncogene expression
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 induced CBFB-MYH11 oncogene expression
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 induced CBFB-MYH11 oncogene expression
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 wild type phenotype
## strain spike-in addition block
## <character> <character> <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 B6D2F1-J ERCC+SIRV 20160113
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 B6D2F1-J ERCC+SIRV 20160113
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 B6D2F1-J ERCC+SIRV 20160113
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 B6D2F1-J ERCC+SIRV 20160113
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 B6D2F1-J ERCC+SIRV 20160113
## ... ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 B6D2F1-J Premixed 20160325
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 B6D2F1-J Premixed 20160325
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 B6D2F1-J Premixed 20160325
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 B6D2F1-J Premixed 20160325
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 B6D2F1-J Premixed 20160325
## sum detected percent_top_50
## <integer> <integer> <numeric>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 865936 7618 26.7218
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 1076277 7521 29.4043
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 1180138 8306 27.3454
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 1342593 8143 35.8092
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 1668311 7154 34.1198
## ... ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 776622 8174 45.9362
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 1299950 8956 38.0829
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 1800696 9530 30.6675
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 46731 6649 32.2998
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 1866692 10964 26.6632
## percent_top_100 percent_top_200
## <numeric> <numeric>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 32.2773 39.7208
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 35.0354 42.2581
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 32.4770 39.3296
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 40.2666 46.2460
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 39.0901 45.6660
## ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 49.7010 54.6101
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 42.8930 49.0622
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 35.5839 41.8550
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 37.9149 44.5999
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 31.2584 37.5608
## percent_top_500 altexps_ERCC_sum
## <numeric> <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 52.9038 65278
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 55.7454 74748
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 51.9337 60878
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 57.1210 60073
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 58.2004 136810
## ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 64.4249 61575
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 60.6675 94982
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 53.6781 113707
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 56.5235 7580
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 48.9489 48664
## altexps_ERCC_detected
## <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 39
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 40
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 42
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 42
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 44
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 39
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 41
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 40
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 44
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 39
## altexps_ERCC_percent altexps_SIRV_sum
## <numeric> <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 6.80658 27828
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 6.28030 39173
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 4.78949 30058
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 4.18567 32542
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 7.28887 71850
## ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 7.17620 19848
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 6.65764 31729
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 5.81467 41116
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 13.48898 1883
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 2.51930 16289
## altexps_SIRV_detected
## <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 7
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 7
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 7
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 7
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 7
## ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 7
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 7
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 7
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 7
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 7
## altexps_SIRV_percent total
## <numeric> <integer>
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 2.90165 959042
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 3.29130 1190198
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 2.36477 1271074
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 2.26741 1435208
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 3.82798 1876971
## ... ... ...
## SLX-11312.N712_S505.H5H5YBBXX.s_8.r_1 2.313165 858045
## SLX-11312.N712_S506.H5H5YBBXX.s_8.r_1 2.224004 1426661
## SLX-11312.N712_S507.H5H5YBBXX.s_8.r_1 2.102562 1955519
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1 3.350892 56194
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1 0.843271 1931645
```
```r
# Revisa el objeto que acabamos de actualizar
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(0):
## assays(1): counts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(1): Length
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(22): Source Name cell line ... altexps_SIRV_percent total
## reducedDimNames(0):
## altExpNames(2): ERCC SIRV
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 41.4 MB
```
```r
## Agrega las cuentas normalizadas (lognorm) de nuevo
sce <- scater::logNormCounts(sce)
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 113 MB
```
```r
# Ejemplo: obtén el subconjunto de células de tipo "wild type"
# Acuérdate que las células son columnas del SCE
sce[, sce$phenotype == "wild type phenotype"]
```
```
## class: SingleCellExperiment
## dim: 46604 96
## metadata(0):
## assays(2): counts logcounts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(1): Length
## colnames(96): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S504.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(23): Source Name cell line ... total sizeFactor
## reducedDimNames(0):
## altExpNames(2): ERCC SIRV
```
```r
# Accesa la información de los genes de nuestro SCE
# ¡Está vació actualmente!
rowData(sce)
```
```
## DataFrame with 46604 rows and 1 column
## Length
## <integer>
## ENSMUSG00000102693 1070
## ENSMUSG00000064842 110
## ENSMUSG00000051951 6094
## ENSMUSG00000102851 480
## ENSMUSG00000103377 2819
## ... ...
## ENSMUSG00000094621 121
## ENSMUSG00000098647 99
## ENSMUSG00000096730 3077
## ENSMUSG00000095742 243
## CBFB-MYH11-mcherry 2998
```
```r
# Ejemplo de una función que agrega campos nuevos en el rowData
sce <- scater::addPerFeatureQC(sce)
# Accesa a la información de las muestras (metadata) en nuestro SCE actualizado
rowData(sce)
```
```
## DataFrame with 46604 rows and 3 columns
## Length mean detected
## <integer> <numeric> <numeric>
## ENSMUSG00000102693 1070 0.0000000 0.000000
## ENSMUSG00000064842 110 0.0000000 0.000000
## ENSMUSG00000051951 6094 0.0000000 0.000000
## ENSMUSG00000102851 480 0.0000000 0.000000
## ENSMUSG00000103377 2819 0.0104167 0.520833
## ... ... ... ...
## ENSMUSG00000094621 121 0.0 0
## ENSMUSG00000098647 99 0.0 0
## ENSMUSG00000096730 3077 0.0 0
## ENSMUSG00000095742 243 0.0 0
## CBFB-MYH11-mcherry 2998 50375.7 100
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 113 MB
```
```r
# Descarga los archivos de anotación de la base de datos de Ensembl
# correspondientes usando los recursos disponibles vía AnnotationHub
library('AnnotationHub')
ah <- AnnotationHub()
```
```
## snapshotDate(): 2020-04-27
```
```r
query(ah, c("Mus musculus", "Ensembl", "v97"))
```
```
## AnnotationHub with 1 record
## # snapshotDate(): 2020-04-27
## # names(): AH73905
## # $dataprovider: Ensembl
## # $species: Mus musculus
## # $rdataclass: EnsDb
## # $rdatadateadded: 2019-05-02
## # $title: Ensembl 97 EnsDb for Mus musculus
## # $description: Gene and protein annotations for Mus musculus based on Ensem...
## # $taxonomyid: 10090
## # $genome: GRCm38
## # $sourcetype: ensembl
## # $sourceurl: http://www.ensembl.org
## # $sourcesize: NA
## # $tags: c("97", "AHEnsDbs", "Annotation", "EnsDb", "Ensembl", "Gene",
## # "Protein", "Transcript")
## # retrieve record with 'object[["AH73905"]]'
```
```r
# Obtén la posición del cromosoma para cada gen
ensdb <- ah[["AH73905"]]
```
```
## loading from cache
```
```r
chromosome <- mapIds(ensdb,
keys = rownames(sce),
keytype = "GENEID",
column = "SEQNAME")
```
```
## Warning: Unable to map 563 of 46604 requested IDs.
```
```r
rowData(sce)$chromosome <- chromosome
# Accesa a la información de las muestras (metadata) en nuestro SCE actualizado
rowData(sce)
```
```
## DataFrame with 46604 rows and 4 columns
## Length mean detected chromosome
## <integer> <numeric> <numeric> <character>
## ENSMUSG00000102693 1070 0.0000000 0.000000 1
## ENSMUSG00000064842 110 0.0000000 0.000000 1
## ENSMUSG00000051951 6094 0.0000000 0.000000 1
## ENSMUSG00000102851 480 0.0000000 0.000000 1
## ENSMUSG00000103377 2819 0.0104167 0.520833 1
## ... ... ... ... ...
## ENSMUSG00000094621 121 0.0 0 GL456372.1
## ENSMUSG00000098647 99 0.0 0 GL456381.1
## ENSMUSG00000096730 3077 0.0 0 JH584292.1
## ENSMUSG00000095742 243 0.0 0 JH584295.1
## CBFB-MYH11-mcherry 2998 50375.7 100 NA
```
```r
## ¿Qué tan grande es el objeto de R?
pryr::object_size(sce)
```
```
## 114 MB
```
```r
# Ejemplo: obtén el subconjunto de datos donde los genes están en el
# cromosoma 3
# NOTA: which() fue necesario para lidear con los nombres de cromosoma que son
# NA
sce[which(rowData(sce)$chromosome == "3"), ]
```
```
## class: SingleCellExperiment
## dim: 2876 192
## metadata(0):
## assays(2): counts logcounts
## rownames(2876): ENSMUSG00000098982 ENSMUSG00000098307 ...
## ENSMUSG00000105990 ENSMUSG00000075903
## rowData names(4): Length mean detected chromosome
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(23): Source Name cell line ... total sizeFactor
## reducedDimNames(0):
## altExpNames(2): ERCC SIRV
```
```r
# Accesa la información de nuestro experimento usando metadata()
# ¡Está vació actualmente!
metadata(sce)
```
```
## list()
```
```r
# La información en el metadata() es como Vegas - todo se vale
metadata(sce) <- list(favourite_genes = c("Shh", "Nck1", "Diablo"),
analyst = c("Pete"))
# Accesa la información de nuestro experimento usando metadata() de
# nuestro objeto actualizado
metadata(sce)
```
```
## $favourite_genes
## [1] "Shh" "Nck1" "Diablo"
##
## $analyst
## [1] "Pete"
```
```r
# Ejemplo: agrega los componentes principales (PCs) de las logcounts
# NOTA: aprenderemos más sobre análisis de componentes principales (PCA) después
sce <- scater::runPCA(sce)
# Revisa el objeto que acabamos de actualizar
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(2): favourite_genes analyst
## assays(2): counts logcounts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(4): Length mean detected chromosome
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(23): Source Name cell line ... total sizeFactor
## reducedDimNames(1): PCA
## altExpNames(2): ERCC SIRV
```
```r
# Accesa la matriz de PCA del componente (slot) reducedDims
reducedDim(sce, "PCA")[1:6, 1:3]
```
```
## PC1 PC2 PC3
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 -18.717668 -27.598132 5.939654
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 -2.480705 -27.564583 4.916567
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 -42.034018 -7.552435 12.126964
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 8.494303 31.833727 15.760853
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 49.737390 4.226795 6.123169
## SLX-9555.N701_S507.C89V9ANXX.s_1.r_1 44.528081 -3.215503 10.384939
```
```r
# Ejemplo, agrega una representación de los logcounts en t-SNE
# NOTA: aprenderemos más sobre t-SNE después
sce <- scater::runTSNE(sce)
# Revisa el objeto que acabamos de actualizar
sce
```
```
## class: SingleCellExperiment
## dim: 46604 192
## metadata(2): favourite_genes analyst
## assays(2): counts logcounts
## rownames(46604): ENSMUSG00000102693 ENSMUSG00000064842 ...
## ENSMUSG00000095742 CBFB-MYH11-mcherry
## rowData names(4): Length mean detected chromosome
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1
## colData names(23): Source Name cell line ... total sizeFactor
## reducedDimNames(2): PCA TSNE
## altExpNames(2): ERCC SIRV
```
```r
# Accesa a la matriz de t-SNE en el componente (slot) de reducedDims
head(reducedDim(sce, "TSNE"))
```
```
## [,1] [,2]
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 5.7709901 2.894348
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 -0.7696283 1.759943
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 6.3715234 4.444638
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 4.5001480 -0.697168
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 -5.6695234 -6.797328
## SLX-9555.N701_S507.C89V9ANXX.s_1.r_1 -6.9533606 -6.374509
```
```r
# Ejemplo: agrega una representación 'manual' de los logcounts en UMAP
# NOTA: aprenderemos más sobre UMAP después y de una forma más sencilla de
# calcularla
u <- uwot::umap(t(logcounts(sce)), n_components = 2)
# Agrega la matriz de UMAP al componente (slot) reducedDims
reducedDim(sce, "UMAP") <- u
# Accesa a la matriz de UMAP desde el componente (slot) reducedDims
head(reducedDim(sce, "UMAP"))
```
```
## [,1] [,2]
## SLX-9555.N701_S502.C89V9ANXX.s_1.r_1 -0.8775856 -3.353889
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 -0.6025560 -1.917092
## SLX-9555.N701_S504.C89V9ANXX.s_1.r_1 -1.2132465 -3.298013
## SLX-9555.N701_S505.C89V9ANXX.s_1.r_1 0.8394168 -1.990511
## SLX-9555.N701_S506.C89V9ANXX.s_1.r_1 1.7126780 -1.390049
## SLX-9555.N701_S507.C89V9ANXX.s_1.r_1 1.1901539 -1.794322
```
```r
# Enumera los resultados de reducción de dimensiones en nuestro objeto SCE
reducedDims(sce)
```
```
## List of length 3
## names(3): PCA TSNE UMAP
```
```r
# Extrae la información de ERCC de nuestro SCE para el set de datos de 416b
ercc.sce.416b <- altExp(sce.416b, "ERCC")
# Inspecciona el SCE para los datos de ERCC
ercc.sce.416b
```
```
## class: SingleCellExperiment
## dim: 92 192
## metadata(0):
## assays(1): counts
## rownames(92): ERCC-00002 ERCC-00003 ... ERCC-00170 ERCC-00171
## rowData names(1): Length
## colnames(192): SLX-9555.N701_S502.C89V9ANXX.s_1.r_1
## SLX-9555.N701_S503.C89V9ANXX.s_1.r_1 ...
## SLX-11312.N712_S508.H5H5YBBXX.s_8.r_1
## SLX-11312.N712_S517.H5H5YBBXX.s_8.r_1