Data Analysis of Microarrays Bioconductor org affy package
Data Analysis of Microarrays Bioconductor. org “affy” package “limma” package
Open R and Load libraries > load(affy)
Affymetrix Data files n n CEL files contain information about the expression levels of the individual probes. CDF file contains information about which probes belong to which probe set. The probe set information in the CEL file by itself is not particularly useful as there is no indication in the file as to which probe set a probe belongs. This information is stored in the CDF library file associated with a chip type. All the arrays belonging to a given type will share this same information.
Analysis n n Sample Generation, experimental design, hybridization =) RAW DATA. Data analysis. ¡ ¡ ¡ n (a) Scanning and image analysis =) PROBE INTENSITIES. [low level analysis] (b) Background correction, normalization and quantifying expression measures =) NORMALIZED EXPRESSION MEASURES FOR EACH GENE (PROBE SET). [low level analysis] (c) Ranking of genes, clustering/classification of genes =) INTERESTING GENE SET. [high level analysis] Validation of the interesting genes: using additional biological data and performing targeted experiments.
Estrogen dataset n n n "The investigators in this experiment were interested in the effect of estrogen on the genes in ER+ breast cancer cells over time. After serum starvation of all eight samples, they exposed four samples to estrogen, and then measured m. RNA transcript abundance after 10 hours for two samples and 48 hours for the other two. They left the remaining four samples untreated, and measured m. RNA transcript abundance at 10 hours for two samples, and 48 hours for the other two. Since there are two factors in this experiment (estrogen and time), each at two levels (present or absent, 10 hours or 48 hours), this experiment is said to have a 2 x 2 factorial design. "
Experimental Design
Put. cel files in a directory n n Estrogen. zip file should be extracted into a file named estrogen. Working directory should be set to this file using the change dir command under the file menu.
Information on chips/samples n A text file that looks like the following should be prepared using a text editor and saved as filename. txt (e. g. , estrogen. txt):
R: read the sample information You have to load the file into a pheno. Data object > pd <read. pheno. Data("estrogen. txt ", header = TRUE, row. names = 1) > p. Data(pd)
pheno. Data objects n pheno. Data objects are where the Bioconductor Package stores information about samples ¡ ¡ treatment conditions in a cell line experiment or clinical or histopathological characteristics of tissue biopsies. The header option lets the read. pheno. Data function know that the first line in the file contains column headings, and the row. names option indicates that the first column of the file contains the row names.
pheno. Data objects > pd <- read. pheno. Data("estrogen. txt", header = TRUE, row. names = 1) > p. Data(pd) estrogen time. h low 10 -1. cel absent 10 low 10 -2. cel absent 10 high 10 -1. cel present 10 high 10 -2. cel present 10 low 48 -1. cel absent 48 low 48 -2. cel absent 48 high 48 -1. cel present 48 high 48 -2. cel present 48
Read. cel files and name the object as a > a <- Read. Affy(filenames = rownames(p. Data(pd)), pheno. Data = pd, + verbose = TRUE) Copy and paste the above statements onto the command line in R
Read. cel files and name the object as a > a <- Read. Affy(filenames = rownames(p. Data(pd)), pheno. Data = pd, + verbose = TRUE) 1 reading low 10 -1. cel. . . instanciating an Affy. Batch (intensity a 409600 x 8 matrix). . . done. Reading in : low 10 -1. cel Reading in : low 10 -2. cel Reading in : high 10 -1. cel Reading in : high 10 -2. cel Reading in : low 48 -1. cel Reading in : low 48 -2. cel Reading in : high 48 -1. cel Reading in : high 48 -2. cel
Type a > a Affy. Batch object size of arrays=640 x 640 features (25606 kb) cdf=HG_U 95 Av 2 (12625 affyids) number of samples=8 number of genes=12625 annotation=hgu 95 av 2
Visualize chips >image(a[, 1])
Visualize log 2 transformed raw values using hist (histogram of distribution) > hist(log 2(intensity(a[, 4])), breaks = 100, col = "blue")
Boxplots >boxplot(a, col = "red")
Normalize data using rma > eset = rma(a) >boxplot(data. frame(exprs(eset)), col = "blue")
MA Plots n n Measurement of relative expression versus Average log intensity plot. Also known as the RI (Ratio versus Intensity). MA plots can show the intensity-dependent ratio of raw microarray data. Let R represent raw intensity for one chip and G represent raw intensity for another chip. Define M = log 2(R/G) A = log 2(RG)1/2.
MA plots after normalization >mva. pairs(exprs(eset)[, c(1, 3, 5, 7)], log. it=FALSE)
MA plots before normalization > mva. pairs(pm(a)[, c(1, 3, 5)])
Memory Problems If you experience memory errors, please restart your R session before trying a less memory-expensive alternative. n The following function just. RMA() should read in all 8 arrays, normalize them, and create an object of class expr. Set with as little as 128 Megabytes of RAM: > library(affy) > pd <- read. pheno. Data("Estrogen. Targets. txt", header=TRUE, row. names=1, as. is=TRUE) > eset <- just. RMA(filenames=p. Data(pd)$File. Name, pheno. Data=pd) > eset n Or to read in only the first four arrays, you can use: >eset <- just. RMA(filenames=p. Data(pd)$File. Name[1: 4], pheno. Data=pd) >eset
Glossary Term Definition Affy. ID An identifier for a probe-pair set. Affymetrix The largest company which manufactures (single-channel) high-density oligonucleotide microarray chips. CDF file Chip Description File. Describes which probes go in which probe sets and the location of probe-pair sets (genes, gene fragments, ESTs). See http: //www. bioconductor. org/data/meta. Data. html CEL file Cell intensity file, including probe level PM and MM values. Cell line Cells grown in tissue culture, representing generations of a primary culture. DAT file Image file, approximately 10^7 pixels, approximately 50 MB.
Glossary Genotype The type of RNA in a biological sample as described by the DNA sequence, e. g. using Single Nucleotide Polymorphisms (SNPs) or microsatellite markers. MAS 5. 0 The main microarray analysis software from the Affymetrix company: Micro. Array. Suite-MAS, now version 5. Mismatch(MM) The same as PM but with a single homomericbase change for the middle (13 th) base (transversionpurine<-> pyrimidine, G <->C, A <->T). The purpose of the MM probe design is to measure non-specific binding and background. Perfect match(PM) A 25 -mer complementary to a reference sequence of interest (e. g. , part of a gene).
Glossary Phenotype The type of RNA in a biological sample as described by physical characteristics of the biological sample, e. g. time or estrogen presence/absence or observed susceptibility to disease. Probe An oligonucleotideof 25 base-pairs, i. e. , a 25 -mer. Probe-pair A (PM, MM) pair. Probe-pair set A collection of probe-pairs (16 to 20) related to a common gene or fraction of a gene. RMA Robust Multichip Averaging (Irizarry et al. [6]). Target A type of RNA under a particular condition (e. g. Estrogen present) which is hybridized to a microarray chip.
Gene Filtering (Genefilter package) > library(genefilter) Loading required package: survival Loading required package: splines > f 1 <- p. Over. A(0. 25, log 2(100)) > f 2 <- function(x) (IQR(x) > 0. 5) > ff <- filterfun(f 1, f 2) > selected <- genefilter(eset, ff) > sum(selected) [1] 1664 > eset. Sub <- eset[selected, ]
See some data > eset. Sub[1: 3, ] Expression Set (expr. Set) with 3 genes 8 samples pheno. Data object with 2 variables and 8 cases var. Labels estrogen: read from file time. h: read from file > exprs(eset. Sub[1: 3, ]) low 10 -1. cel low 10 -2. cel high 10 -1. cel high 10 -2. cel low 48 -1. cel 1005_at 9. 206734 8. 993805 8. 237886 8. 338003 9. 173192 1008_f_at 10. 119335 10. 986661 10. 830301 10. 025106 11. 044671 1009_at 10. 553034 10. 500375 11. 159770 11. 048265 10. 211211 low 48 -2. cel high 48 -1. cel high 48 -2. cel 1005_at 9. 040490 7. 926101 8. 06968 1008_f_at 11. 138321 10. 705763 11. 36952 1009_at 9. 565864 11. 363234 10. 76293
Clustering Algorithms in R n Two main categories ¡ ¡ Agglomerative (e. g. , hierarchical) Partitioning (e. g. , kmeans)
Clustering Algorithms in R n n n First, dist is used to compute distances. This function takes a matrix as its first argument and computes the distances between the rows of the matrix. We will use the expression data matrix from estrogen for this purpose The commands below are used to carry out hierarchical clustering using the Manhattan distance metric and to plot the corresponding dendrogram with nodes labeled according to file names.
Cluster data (hierarchical) > dg. Tr <- dist(t(exprs(eset. Sub)), method = "manhattan") > hcg. Tr <- hclust(dg. Tr, method = "average")
Cluster data (hierarchical) > kmg. Tr <- kmeans(t(exprs(eset. Sub)), centers = 2) > kmg. Tr$cluster low 10 -1. cel low 10 -2. cel high 10 -1. cel high 10 -2. cel low 48 -2. cel 1 1 2 2 1 high 48 -1. cel high 48 -2. cel 2 2 low 48 -1. cel 1
T-test on a subset of estrogen data >sub. EST=exprs(eset[, 1: 4]); > group 1=c(1, 1, 2, 2) > group 1 [1] 1 1 2 2 > sub. EST Expression Set (expr. Set) with 12625 genes 4 samples pheno. Data object with 2 variables and 4 cases var. Labels estrogen: read from file time. h: read from file > tf 1 <- ttest(group 1, 0. 1) > ff 2 <- filterfun(tf 1) > wh 2 <- genefilter(exprs(sub. EST), ff 2) > sum(wh 2) [1] 1711 >
Apo. AI data n The data is from a study of lipid metabolism by Callow et al (2000). The apolipoprotein AI (Apo. AI) gene is known to play a pivotal role in high density lipoprotein (HDL) metabolism. Mice which have the Apo. AI gene knocked out have very low HDL cholesterol levels. The purpose of this experiment is to determine how Apo. AI deficiency affects the action of other genes in the liver, with the idea that this will help determine the molecular pathways through which Apo. AI operates.
Hybridizations n The experiment compared 8 Apo. AI knockout mice with 8 wild type (normal) C 57 BL/6 ("black six") mice, the control mice. For each of these 16 mice, target m. RNA was obtained from liver tissue and labelled using a Cy 5 dye. The RNA from each mouse was hybridized to a separate microarray. Common reference RNA was labelled with Cy 3 dye and used for all the arrays. The reference RNA was obtained by pooling RNA extracted from the 8 control mice.
Experimental Design
Load data > library(limma) > load("Apo. AI. RData") > objects() [1] "last. warning" "mart" > names(RG) [1] "R" "G" "Rb" "genes" "targets" "RG" "Gb" "printer"
What did you download? > RG$targets File. Name c 1 a 1 koc 1. spot c 2 a 1 koc 2. spot c 3 a 1 koc 3. spot c 4 a 1 koc 4. spot c 5 a 1 koc 5. spot c 6 a 1 koc 6. spot c 7 a 1 koc 7. spot c 8 a 1 koc 8. spot k 1 a 1 kok 1. spot k 2 a 1 kok 2. spot k 3 a 1 kok 3. spot k 4 a 1 kok 4. spot k 5 a 1 kok 5. spot k 6 a 1 kok 6. spot k 7 a 1 kok 7. spot k 8 a 1 kok 8. spot Cy 3 Pool Pool Pool Pool Cy 5 C 57 BL/6 C 57 BL/6 Apo. AI-/Apo. AI-/-
What does RG contain n Type in RG at the command line: >RG $R [1, ] [2, ] [3, ] [4, ] [5, ] 6379 a 1 koc 1 a 1 koc 2 4184. 08 3300. 22 4148. 48 3774. 18 2452. 32 3028. 47 1577. 31 1999. 92 1525. 48 1967. 44 a 1 kok 2 a 1 kok 3 2330. 53 2630. 76 3027. 00 2411. 81 2235. 84 2343. 61 1313. 93 1551. 66 1288. 93 1378. 91 more rows. . . a 1 koc 3 2432. 54 2579. 92 3574. 45 1296. 81 1210. 10 a 1 kok 4 2234. 17 2023. 39 4196. 89 1359. 58 1216. 87 a 1 koc 4 2069. 81 2566. 33 2348. 09 1926. 69 1929. 64 a 1 kok 5 2811. 72 4148. 58 2079. 53 1305. 88 1218. 35 a 1 koc 5 2809. 83 2286. 43 4462. 67 1010. 74 950. 80 a 1 kok 6 2721. 10 3384. 13 4344. 00 1512. 14 1205. 67 a 1 koc 6 2029. 05 2244. 33 2703. 20 1764. 58 1638. 89 a 1 kok 7 2361. 67 2763. 00 3051. 24 1617. 78 1412. 08 a 1 koc 7 1720. 56 1987. 83 1543. 10 1161. 71 936. 42 a 1 kok 8 2585. 89 2775. 44 3277. 82 1584. 25 1666. 32 a 1 koc 8 1795. 58 1908. 33 2123. 91 1495. 13 1540. 65 a 1 kok 1 1845. 97 2924. 68 1702. 91 1778. 82 1554. 96
What does RG contain $G [1, ] [2, ] [3, ] [4, ] [5, ] 6379 a 1 koc 1 a 1 koc 2 6256. 08 5269. 89 5389. 81 3608. 12 2653. 29 4168. 16 1071. 26 1162. 71 1321. 75 1148. 64 a 1 kok 2 a 1 kok 3 2558. 68 1724. 41 1943. 40 1100. 10 2404. 77 3011. 42 583. 08 873. 06 536. 43 656. 76 more rows. . . a 1 koc 3 4080. 85 2614. 42 8091. 95 819. 13 642. 94 a 1 kok 4 2309. 08 1233. 33 3708. 85 737. 57 593. 17 a 1 koc 4 3229. 38 2107. 56 3134. 39 1295. 82 1289. 74 a 1 kok 5 2758. 44 2337. 75 2830. 40 834. 58 679. 73 a 1 koc 5 3763. 22 1878. 30 3046. 00 428. 95 500. 49 a 1 kok 6 2632. 43 1630. 91 3030. 90 887. 97 756. 44 a 1 koc 6 2773. 58 1926. 00 3612. 40 900. 78 684. 00 a 1 kok 7 1955. 33 1422. 45 2809. 82 827. 38 572. 64 a 1 koc 7 a 1 koc 8 a 1 kok 1 2800. 44 1923. 58 804. 80 1711. 17 1205. 20 1385. 96 2002. 62 1651. 41 915. 24 838. 19 689. 00 763. 64 571. 92 736. 41 685. 88 a 1 kok 8 3191. 78 1961. 50 2482. 39 890. 58 1233. 45
What does RG contain $Rb [1, ] [2, ] [3, ] [4, ] [5, ] 6379 a 1 koc 1 a 1 koc 2 a 1 koc 3 a 1 koc 4 a 1 koc 5 a 1 koc 6 1418. 50 1532. 00 992. 00 1306. 75 781. 89 1165 1280. 05 1497. 00 980. 00 1328. 00 773. 00 1165 1216. 00 1481. 63 935. 00 1348. 61 773. 00 1198 1193. 69 1467. 42 973. 26 1341. 55 760. 00 1198 1148. 12 1442. 00 929. 43 1376. 21 760. 00 1177 a 1 kok 3 a 1 kok 4 a 1 kok 5 a 1 kok 6 a 1 kok 7 a 1 kok 8 1042. 00 954. 00 930. 00 987. 57 1190. 83 1073. 44 1042. 00 952. 22 930. 00 933. 09 1158. 00 1074. 62 1042. 00 904. 63 930. 30 919. 70 1150. 18 1077. 00 1037. 75 899. 89 914. 79 911. 14 1179. 75 1077. 00 1023. 15 898. 00 892. 76 882. 02 1069. 02 1064. 04 more rows. . . a 1 koc 7 761. 88 759. 17 758. 00 752. 53 710. 79 a 1 koc 8 a 1 kok 1 a 1 kok 2 1151. 00 1098. 86 941. 74 1151. 00 994. 43 934. 00 1129. 05 949. 39 935. 84 1077. 34 949. 00 911. 09 1075. 00 920. 16 898. 00
What does RG contain $Gb [1, ] [2, ] [3, ] [4, ] [5, ] 6379 a 1 koc 1 a 1 koc 2 663. 50 520. 00 643. 43 520. 00 544. 81 498. 63 522. 80 454. 55 465. 27 433. 00 a 1 kok 3 a 1 kok 4 282. 53 254. 00 264. 24 254. 00 250. 06 254. 00 233. 66 244. 56 231. 00 231. 05 more rows. . . a 1 koc 3 371. 54 355. 00 317. 55 356. 46 295. 67 a 1 kok 5 321. 28 309. 00 305. 00 297. 75 298. 74 a 1 koc 4 563. 25 589. 44 619. 58 615. 76 567. 81 a 1 kok 6 363. 00 336. 00 335. 46 334. 22 a 1 koc 5 228. 00 231. 00 218. 37 203. 00 a 1 kok 7 285. 00 286. 78 274. 44 a 1 koc 6 274. 05 268. 00 267. 00 a 1 kok 8 309. 00 309. 86 351. 78 358. 92 a 1 koc 7 354. 50 324. 61 281. 66 289. 30 238. 42 a 1 koc 8 292. 00 286. 93 264. 00 257. 82 a 1 kok 1 224. 00 206. 86 181. 00 174. 57 a 1 kok 2 239. 95 239. 00 248. 18 229. 10
What does RG contain $genes Grid. ROW Grid. COL ROW COL NAME TYPE CLID ACC 1 1 1 Cy 3 RT Control BLANK 2 1 1 1 2 Cy 5 RT Control BLANK 3 1 1 1 3 m. SRB 1 c. DNA m. SRB 1 4 1 1 1 4 BLANK 5 1 1 1 5 BLANK 6379 more rows. . . $targets File. Name Cy 3 c 1 a 1 koc 1. spot Pool c 2 a 1 koc 2. spot Pool c 3 a 1 koc 3. spot Pool c 4 a 1 koc 4. spot Pool c 5 a 1 koc 5. spot Pool 11 more rows. . . Cy 5 C 57 BL/6 C 57 BL/6
Exercise > dim(RG) [1] 6384 16 > ncol(RG) [1] 16 > colnames(RG) [1] "a 1 koc 1" "a 1 koc 2" "a 1 koc 3" "a 1 koc 4""a 1 koc 5" "a 1 koc 6" "a 1 koc 7" "a 1 koc 8" [9] "a 1 kok 1" "a 1 kok 2" "a 1 kok 3" "a 1 kok 4""a 1 kok 5" "a 1 kok 6" "a 1 kok 7" "a 1 kok 8"
subsets > RG[1: 2, ] An object of class "RGList" $R a 1 koc 1 a 1 koc 2 a 1 koc 3 a 1 koc 4 a 1 koc 5 a 1 koc 6 a 1 koc 7 a 1 koc 8 a 1 kok 1 [1, ] 4184. 08 3300. 22 2432. 54 2069. 81 2809. 83 2029. 05 1720. 56 1795. 58 1845. 97 [2, ] 4148. 48 3774. 18 2579. 92 2566. 33 2286. 43 2244. 33 1987. 83 1908. 33 2924. 68 a 1 kok 2 a 1 kok 3 a 1 kok 4 a 1 kok 5 a 1 kok 6 a 1 kok 7 a 1 kok 8 [1, ] 2330. 53 2630. 76 2234. 17 2811. 72 2721. 10 2361. 67 2585. 89 [2, ] 3027. 00 2411. 81 2023. 39 4148. 58 3384. 13 2763. 00 2775. 44 $G a 1 koc 1 a 1 koc 2 a 1 koc 3 a 1 koc 4 a 1 koc 5 a 1 koc 6 a 1 koc 7 a 1 koc 8 a 1 kok 1 [1, ] 6256. 08 5269. 89 4080. 85 3229. 38 3763. 22 2773. 58 2800. 44 1923. 58 804. 80 [2, ] 5389. 81 3608. 12 2614. 42 2107. 56 1878. 30 1926. 00 1711. 17 1205. 20 1385. 96 a 1 kok 2 a 1 kok 3 a 1 kok 4 a 1 kok 5 a 1 kok 6 a 1 kok 7 a 1 kok 8 [1, ] 2558. 68 1724. 41 2309. 08 2758. 44 2632. 43 1955. 33 3191. 78 [2, ] 1943. 40 1100. 10 1233. 33 2337. 75 1630. 91 1422. 45 1961. 50
Background correction n RG. b <background. Correct(RG, method="minimum")
Loess normalization >plot. Densities(MA. p)
Quantile Normalization > > MA. p. Aq <- normalize. Between. Arrays(MA. p, method="Aquantile") plot. Densities(MA. p. Aq)
Print-tip loess normalization > MA <- normalize. Within. Arrays(RG)
Generate factors > design <- cbind("WT-Ref"=1, "KO-WT"=rep(0: 1, c(8, 8))) > design WT-Ref KO-WT [1, ] 1 0 [2, ] 1 0 [3, ] 1 0 [4, ] 1 0 [5, ] 1 0 [6, ] 1 0 [7, ] 1 0 [8, ] 1 0 [9, ] 1 1 [10, ] 1 1 [11, ] 1 1 [12, ] 1 1 [13, ] 1 1 [14, ] 1 1 [15, ] 1 1 [16, ] 1 1
Fit a linear model > fit <- lm. Fit(MA, design=design) > fit An object of class "MArray. LM" $coefficients WT-Ref KO-WT [1, ] -0. 65953808 0. 63931974 [2, ] 0. 22938847 0. 65516034 [3, ] -0. 25176365 0. 33421048 [4, ] -0. 05169672 0. 04049065 [5, ] -0. 25006850 0. 22302129 6379 more rows. . .
Ebayes fit n fit <- e. Bayes(fit)
Significance n $p. value WT-Ref KO-WT [1, ] 0. 0005273336 0. 009821223 [2, ] 0. 0840905898 0. 001674820 [3, ] 0. 2514756923 0. 280677844 [4, ] 0. 5306727045 0. 727393168 [5, ] 0. 0140994442 0. 103570036 6379 more rows. . . n $lods n WT-Ref KO-WT [1, ] -0. 1466897 -2. 581616 [2, ] -4. 8450256 -1. 065213 [3, ] -5. 7239418 -5. 260559 [4, ] -6. 2106950 -5. 777607 [5, ] -3. 2510578 -4. 528469 6379 more rows. . . n n n n n $F [1] 8. 8907738 26. 5502551 0. 7775771 0. 2140163 3. 7423046 6379 more elements. . . $F. p. value [1] 2. 085929 e-03 4. 429307 e-06 4. 744446 e-01 8. 093730 e-01 4. 388436 e-02 6379 more elements. . .
Top table > top. Table(fit, coef="KO-WT", adjust="fdr") Grid. ROW Grid. COL ROW COL NAME TYPE CLID ACC 2149 2 2 8 7 Apo. AI, lipid-Img c. DNA 1077520 540 1 2 7 15 EST, Highlysimilarto. A c. DNA 439353 5356 4 2 9 1 CATECHOLO-METHYLTRAN c. DNA 1350232 4139 3 3 8 2 EST, Weaklysimilarto. C c. DNA 374370 1739 2 1 7 17 Apo. CIII, lipid-Img c. DNA 483614 2537 2 3 7 17 ESTs, Highlysimilarto c. DNA 483614 1496 1 4 15 5 est c. DNA 484183 genome. wustl 4941 4 1 8 6 similartoyeaststerol c. DNA 737183 947 1 3 8 2 EST, Weaklysimilarto. F c. DNA 353292 5604 4 3 1 18 c. DNA 317638 M A t P. Value B 2149 -3. 1661645 12. 46803 -23. 980007 3. 045649 e-11 14. 9266311 540 -3. 0485504 12. 28064 -12. 962085 5. 020967 e-07 10. 8133421 5356 -1. 8481659 12. 92660 -12. 440765 6. 505619 e-07 10. 4479375 4139 -1. 0269537 12. 60572 -11. 756162 1. 209061 e-06 9. 9285280 1739 -0. 9325824 13. 73744 -9. 835355 1. 563760 e-05 8. 1924099 2537 -1. 0098117 13. 63012 -9. 015243 4. 222433 e-05 7. 3048994 1496 -0. 9774236 12. 22891 -9. 002324 4. 222433 e-05 7. 2901336 4941 -0. 9549693 13. 28750 -7. 441333 5. 617334 e-04 5. 3106653 947 -0. 5705900 10. 54291 -4. 554709 1. 768067 e-01 0. 5629149 5604 -0. 3663573 12. 71267 -3. 962815 5. 290409 e-01 -0. 5532768
MA plots > plot. MA(fit, 2)
Venn diagram > results <- decide. Tests(fit) > venn. Diagram(results)
Switch function center = function(x, type) { switch(type, mean = mean(x), median = median(x), trimmed = mean(x, trim =. 1)) }
Switch function The switch function uses the value of its first argument to determine which of its remaining arguments to evaluate and return. The first argument can be either an integer index, or a character string to be used in matching one of the following arguments.
Apply function For example, > apply(x, 2, mean) n computes the column means of a matrix x, while > apply(x, 1, median) n n computes the row medians.
- Slides: 58