These exercises are about the vector sections of Introduction to R.
Exercise 1
<- c(1,2,3,4,5)
x x
## [1] 1 2 3 4 5
<- 1:100
x x
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
## [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
## [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
## [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
## [91] 91 92 93 94 95 96 97 98 99 100
<- seq(0,20,5)
x x
## [1] 0 5 10 15 20
<- x[-c(1,length(x))]
y y
## [1] 5 10 15
Exercise 2
<- data.frame(geneNames=c("Gene_1", "Gene_2", "Gene_3","Gene_4","Gene_5"), ensembl=c("Ens001", "Ens003", "Ens006", "Ens007", "Ens010"),pathway=c("Glycolysis", "TGFb", "Glycolysis", "TGFb", "Glycolysis"),geneLengths=c(100, 3000, 200, 1000,1200)) Annotation
$expression <- c(1000, 3000, 10000,5000,50) Annotation
<- Annotation[1:2,-2]
Annotation_subset Annotation_subset
## geneNames pathway geneLengths expression
## 1 Gene_1 Glycolysis 100 1000
## 2 Gene_2 TGFb 3000 3000
<- Annotation[(nrow(Annotation)-1):nrow(Annotation),-c(4,5)]
Annotation_subset2 Annotation_subset2
## geneNames ensembl pathway
## 4 Gene_4 Ens007 TGFb
## 5 Gene_5 Ens010 Glycolysis
$len_norm_exp <- Annotation$expression / Annotation$geneLengths
Annotation Annotation
## geneNames ensembl pathway geneLengths expression len_norm_exp
## 1 Gene_1 Ens001 Glycolysis 100 1000 10.00000000
## 2 Gene_2 Ens003 TGFb 3000 3000 1.00000000
## 3 Gene_3 Ens006 Glycolysis 200 10000 50.00000000
## 4 Gene_4 Ens007 TGFb 1000 5000 5.00000000
## 5 Gene_5 Ens010 Glycolysis 1200 50 0.04166667