knitting this
fileWhereami? Print your working directory to the screen
## One line of code here:
getwd()
## [1] "C:/Users/becamach/OneDrive - North Carolina State University/Documents/DSA595/1"
Use R as a simple calculator to type in 3 or 4 mathematical operations and print to screen
## Example ##
2+2
## [1] 4
## Your mathematical commands here
2-1
## [1] 1
3-2
## [1] 1
4-3
## [1] 1
rnorm() function create:
x with 100 values drawn from a random
normal distributionplot() function to plot x and
change points to solid and color to red and title the plot,
“100 values drawn from a random normal distribution”
?plot.default will helpboxplot() function to plot x and
change color## Your code here
rnorm(100)
## [1] 0.430738547 0.460776077 1.456082610 0.343076945 -0.670456504
## [6] -0.818092749 -1.084459555 0.744349420 1.516161917 -0.039247152
## [11] 0.021904154 0.073366473 -1.086852629 1.092775920 0.991422334
## [16] -0.459911317 -1.096716788 0.651742700 -0.431409530 1.423526334
## [21] -0.840078883 0.828143428 -0.281383711 1.912248786 -0.193891433
## [26] 0.194682910 0.490873853 -1.501149192 0.145351908 -0.083294606
## [31] -0.703410170 0.409220778 0.470836260 1.509841292 -0.509028093
## [36] -0.747763531 0.987717528 1.592291330 0.564064916 -0.147385588
## [41] -0.063352974 -1.462386125 0.260251499 0.926496891 1.695760365
## [46] 1.533862308 0.604777707 1.148937016 -2.153685351 0.189543762
## [51] -0.631703710 -1.745120676 -1.743003876 1.121635720 -1.610091807
## [56] -0.462948921 0.344443445 -0.009992215 1.005231934 -0.593001677
## [61] -0.311869639 0.234199804 0.753151512 -0.450398413 1.055566672
## [66] 0.729623570 -2.113133238 -1.120317132 -1.408008359 -0.082920817
## [71] -1.223718811 0.027011435 1.365650576 -2.121525101 0.976989469
## [76] 1.226896164 0.438364714 0.727322861 -1.109628263 1.047949925
## [81] -2.010517461 1.258946612 -0.476076731 -0.477591101 0.184323870
## [86] -1.481039431 1.143937431 0.549077514 -1.136356125 0.039424853
## [91] -0.654251079 -1.110931663 0.996765055 0.339018514 0.682409348
## [96] -0.336832698 0.318969258 0.311816702 -1.746584632 0.915916483
x <- rnorm(100)
plot(x, pch = 19, main= '100 values drawn from a random normal distribution', col="red")
boxplot(x, col = "deeppink")
I’ve downloaded and unzipped a dataset with summary level information from the GTEx portal. https://gtexportal.org/home/downloads/adult-gtex/bulk_tissue_expression
names() functionhead() function## Read in the file
## I've provided this for you - Do not change the next line
gtex_summary_data <- read.delim2("GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_median_tpm.gct", skip = 2)
## Convert expression data columns to numeric
## I've provided this for you - Do not change the next line
gtex_summary_data[3:56] <- lapply(gtex_summary_data[3:56], as.numeric)
## Round Data to 3 decimal places for ease of printing
## I've provided this for you - Do not change the next line
gtex_summary_data[3:56] <- lapply(gtex_summary_data[3:56], function(x) round(x,3))
## Ask R for column names of the gtex_summary_data dataset
# Your code here
colnames(gtex_summary_data, prefix = "col")
## [1] "Name"
## [2] "Description"
## [3] "Adipose...Subcutaneous"
## [4] "Adipose...Visceral..Omentum."
## [5] "Adrenal.Gland"
## [6] "Artery...Aorta"
## [7] "Artery...Coronary"
## [8] "Artery...Tibial"
## [9] "Bladder"
## [10] "Brain...Amygdala"
## [11] "Brain...Anterior.cingulate.cortex..BA24."
## [12] "Brain...Caudate..basal.ganglia."
## [13] "Brain...Cerebellar.Hemisphere"
## [14] "Brain...Cerebellum"
## [15] "Brain...Cortex"
## [16] "Brain...Frontal.Cortex..BA9."
## [17] "Brain...Hippocampus"
## [18] "Brain...Hypothalamus"
## [19] "Brain...Nucleus.accumbens..basal.ganglia."
## [20] "Brain...Putamen..basal.ganglia."
## [21] "Brain...Spinal.cord..cervical.c.1."
## [22] "Brain...Substantia.nigra"
## [23] "Breast...Mammary.Tissue"
## [24] "Cells...Cultured.fibroblasts"
## [25] "Cells...EBV.transformed.lymphocytes"
## [26] "Cervix...Ectocervix"
## [27] "Cervix...Endocervix"
## [28] "Colon...Sigmoid"
## [29] "Colon...Transverse"
## [30] "Esophagus...Gastroesophageal.Junction"
## [31] "Esophagus...Mucosa"
## [32] "Esophagus...Muscularis"
## [33] "Fallopian.Tube"
## [34] "Heart...Atrial.Appendage"
## [35] "Heart...Left.Ventricle"
## [36] "Kidney...Cortex"
## [37] "Kidney...Medulla"
## [38] "Liver"
## [39] "Lung"
## [40] "Minor.Salivary.Gland"
## [41] "Muscle...Skeletal"
## [42] "Nerve...Tibial"
## [43] "Ovary"
## [44] "Pancreas"
## [45] "Pituitary"
## [46] "Prostate"
## [47] "Skin...Not.Sun.Exposed..Suprapubic."
## [48] "Skin...Sun.Exposed..Lower.leg."
## [49] "Small.Intestine...Terminal.Ileum"
## [50] "Spleen"
## [51] "Stomach"
## [52] "Testis"
## [53] "Thyroid"
## [54] "Uterus"
## [55] "Vagina"
## [56] "Whole.Blood"
## Ask R for first 6 records of the gtex_summary_data dataset
# Your code here
head(gtex_summary_data, n=6)
## Name Description Adipose...Subcutaneous
## 1 ENSG00000223972.5 DDX11L1 0.000
## 2 ENSG00000227232.5 WASH7P 4.064
## 3 ENSG00000278267.1 MIR6859-1 0.000
## 4 ENSG00000243485.5 MIR1302-2HG 0.000
## 5 ENSG00000237613.2 FAM138A 0.000
## 6 ENSG00000268020.3 OR4G4P 0.000
## Adipose...Visceral..Omentum. Adrenal.Gland Artery...Aorta Artery...Coronary
## 1 0.000 0.000 0.000 0.000
## 2 3.371 2.685 4.048 3.901
## 3 0.000 0.000 0.000 0.000
## 4 0.000 0.000 0.000 0.000
## 5 0.000 0.000 0.000 0.000
## 6 0.000 0.036 0.000 0.000
## Artery...Tibial Bladder Brain...Amygdala
## 1 0.00 0.000 0.000
## 2 3.64 5.164 1.439
## 3 0.00 0.000 0.000
## 4 0.00 0.000 0.000
## 5 0.00 0.000 0.000
## 6 0.00 0.035 0.050
## Brain...Anterior.cingulate.cortex..BA24. Brain...Caudate..basal.ganglia.
## 1 0.000 0.000
## 2 1.693 1.566
## 3 0.000 0.000
## 4 0.000 0.024
## 5 0.000 0.000
## 6 0.054 0.046
## Brain...Cerebellar.Hemisphere Brain...Cerebellum Brain...Cortex
## 1 0.000 0.000 0.000
## 2 4.992 5.721 2.483
## 3 0.000 0.000 0.000
## 4 0.000 0.000 0.027
## 5 0.000 0.000 0.000
## 6 0.025 0.037 0.043
## Brain...Frontal.Cortex..BA9. Brain...Hippocampus Brain...Hypothalamus
## 1 0.000 0.000 0.000
## 2 2.147 1.686 1.748
## 3 0.000 0.000 0.000
## 4 0.030 0.000 0.025
## 5 0.000 0.000 0.000
## 6 0.042 0.053 0.040
## Brain...Nucleus.accumbens..basal.ganglia. Brain...Putamen..basal.ganglia.
## 1 0.000 0.000
## 2 1.539 1.442
## 3 0.000 0.000
## 4 0.031 0.023
## 5 0.000 0.000
## 6 0.045 0.048
## Brain...Spinal.cord..cervical.c.1. Brain...Substantia.nigra
## 1 0.000 0.000
## 2 2.730 1.742
## 3 0.000 0.000
## 4 0.000 0.020
## 5 0.000 0.000
## 6 0.042 0.047
## Breast...Mammary.Tissue Cells...Cultured.fibroblasts
## 1 0.000 0.000
## 2 4.439 1.679
## 3 0.000 0.000
## 4 0.000 0.000
## 5 0.000 0.000
## 6 0.030 0.000
## Cells...EBV.transformed.lymphocytes Cervix...Ectocervix Cervix...Endocervix
## 1 0.000 0.000 0.000
## 2 2.495 5.629 7.097
## 3 0.000 0.000 0.000
## 4 0.000 0.000 0.000
## 5 0.000 0.000 0.000
## 6 0.000 0.000 0.024
## Colon...Sigmoid Colon...Transverse Esophagus...Gastroesophageal.Junction
## 1 0.000 0.000 0.000
## 2 4.648 3.595 4.326
## 3 0.000 0.000 0.000
## 4 0.000 0.000 0.000
## 5 0.000 0.000 0.000
## 6 0.015 0.033 0.036
## Esophagus...Mucosa Esophagus...Muscularis Fallopian.Tube
## 1 0.000 0.000 0.000
## 2 3.117 4.103 6.134
## 3 0.000 0.000 0.000
## 4 0.000 0.000 0.000
## 5 0.000 0.000 0.000
## 6 0.000 0.000 0.000
## Heart...Atrial.Appendage Heart...Left.Ventricle Kidney...Cortex
## 1 0.000 0.000 0.000
## 2 1.520 0.925 2.771
## 3 0.000 0.000 0.000
## 4 0.000 0.018 0.018
## 5 0.000 0.000 0.000
## 6 0.036 0.051 0.039
## Kidney...Medulla Liver Lung Minor.Salivary.Gland Muscle...Skeletal
## 1 0.000 0.000 0.000 0.000 0.000
## 2 2.215 1.765 4.508 3.528 1.417
## 3 0.000 0.000 0.000 0.000 0.000
## 4 0.000 0.000 0.000 0.000 0.000
## 5 0.000 0.000 0.000 0.000 0.000
## 6 0.000 0.033 0.000 0.000 0.038
## Nerve...Tibial Ovary Pancreas Pituitary Prostate
## 1 0.000 0.000 0.000 0.000 0.000
## 2 6.685 6.634 1.809 5.425 7.083
## 3 0.000 0.000 0.000 0.000 0.000
## 4 0.000 0.000 0.000 0.000 0.000
## 5 0.000 0.000 0.000 0.000 0.000
## 6 0.000 0.000 0.000 0.000 0.021
## Skin...Not.Sun.Exposed..Suprapubic. Skin...Sun.Exposed..Lower.leg.
## 1 0.000 0.000
## 2 5.933 6.133
## 3 0.000 0.000
## 4 0.000 0.000
## 5 0.000 0.000
## 6 0.027 0.000
## Small.Intestine...Terminal.Ileum Spleen Stomach Testis Thyroid Uterus Vagina
## 1 0.000 0.000 0.000 0.166 0.000 0.00 0.000
## 2 4.194 5.926 3.062 4.703 6.273 7.19 5.746
## 3 0.000 0.000 0.000 0.000 0.000 0.00 0.000
## 4 0.000 0.000 0.000 0.054 0.000 0.00 0.000
## 5 0.000 0.000 0.000 0.000 0.000 0.00 0.000
## 6 0.035 0.000 0.033 0.000 0.000 0.00 0.000
## Whole.Blood
## 1 0.000
## 2 2.647
## 3 0.000
## 4 0.000
## 5 0.000
## 6 0.000
$plot() with red circlesx is a column of the dataset, then
log2(x+1) will add 1 to every value and take the log2 of
it?base::plot at the
console if you need to see the options for plot## Your code here
plot(x= gtex_summary_data$Liver,y= gtex_summary_data$Lung, col = "red", xlab = "Liver", ylab = "Lung", main = "Liver vs Lung plot")
plot(x= gtex_summary_data$Liver,y= gtex_summary_data$Lung, log = "xy", xlab = "Log Liver", ylab = "Log Lung", main = "Log plot Liver vs Lung")
## Warning in xy.coords(x, y, xlabel, ylabel, log): 29640 x values <= 0 omitted
## from logarithmic plot
## Warning in xy.coords(x, y, xlabel, ylabel, log): 26151 y values <= 0 omitted
## from logarithmic plot