forked from cambiotraining/r-intro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution-exercise9.Rmd
More file actions
42 lines (34 loc) · 895 Bytes
/
solution-exercise9.Rmd
File metadata and controls
42 lines (34 loc) · 895 Bytes
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
---
title: "Exercise 9"
author: "Your Name"
date: '`r format(Sys.time(), "%d %b %Y")`'
output: pdf_document
---
```{r}
genes <- read.delim("gene.description.txt")
subjects <- read.delim("cancer.patients.txt")
evals <- read.delim("gene.expression.txt",stringsAsFactors = FALSE)
```
```{r}
chr8Genes <- genes[genes$Chromosome=="chr8",]
head(chr8Genes)
```
```{r}
chr8GenesOrd <-chr8Genes[order(chr8Genes$Start),]
head(chr8GenesOrd)
```
```{r}
chr8Expression <- evals[match(chr8GenesOrd$probe,rownames(evals)),]
```
- Create a for loop to perform to test if the expression level of each gene on chromosome 8 is significantly different between ER positive and negative samples
```{r}
ngenes <- nrow(chr8Expression)
pvals <- NULL
for(i in 1:ngenes) {
tmp <- t.test(as.numeric(chr8Expression[i,]) ~ subjects$er)
pvals[i] <- tmp$p.value
}
pvals
table(pvals < 0.05)
sum(pvals < 0.05)
```