These exercises are about the matrices sections of Introduction to R.

These exercises cover the matrices sections of Introduction to R.

Exercise 1

##        expression geneLengths
## Gene_1       1000         100
## Gene_2       3000        3000
## Gene_3      10000         200
## Gene_4      12000        1000

HINT - We calculated LNE before in vectors exercises’ bonus question

##        expression geneLengths lne
## Gene_1       1000         100  10
## Gene_2       3000        3000   1
## Gene_3      10000         200  50
## Gene_4      12000        1000  12
##        expression geneLengths lne
## Gene_2       3000        3000   1
## Gene_4      12000        1000  12
##        expression lne
## Gene_2       3000   1
## Gene_4      12000  12
##        expression geneLengths lne  GOterms                             
## Gene_1 "1000"     "100"       "10" "Positively Regulates Transcription"
## Gene_2 "3000"     "3000"      "1"  "Negatively Regulates Transcription"
## Gene_3 "10000"    "200"       "50" "Positively Regulates Transcription"
## Gene_4 "12000"    "1000"      "12" "Regulates Autophagy"
class(geneMatrix_GO)
## [1] "matrix" "array"
is.numeric(geneMatrix_GO)
## [1] FALSE
is.character(geneMatrix_GO)
## [1] TRUE
class(geneMatrix)
## [1] "matrix" "array"
is.numeric(geneMatrix)
## [1] TRUE
is.character(geneMatrix)
## [1] FALSE
geneMatrix_transcription <- geneMatrix[grepl("transcription",GOterms, ignore.case = T),]

geneMatrix_transcription
##        expression geneLengths lne
## Gene_1       1000         100  10
## Gene_2       3000        3000   1
## Gene_3      10000         200  50
is.numeric(geneMatrix_transcription)
## [1] TRUE

Bonus Question

- Calculate the sum of expression and length columns for only genes with length > 100.

##  expression geneLengths 
##       25000        4200