-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_tissue_specific_genes.R
executable file
·61 lines (48 loc) · 2.24 KB
/
get_tissue_specific_genes.R
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#### Instead of testing (tissues are too different to be normalized together), I will follow Wolfgang Huber's advice: "Why not do something pragmatic, like choosing all genes that are higher (lower) in all replicates of gonad than in all replicates of intestine. Or, all genes that are tissue-specific?" and "I would suggest to derive some pragmatic rule for what you call expressed (e.g. RPKM>5) and not expressed (e.g. RPKM<0.5) - you can do various diagnostic plots to tune these parameters."
setwd("~/Shuo_Katja")
library(Biobase)
load("Data/eset_fpkm_intestine_plus_gonad.RData")
eset <- eset.fpkm
## I will only look at empty vector samples:
eset <- eset[, pData(eset)$condition == "empty vector"]
## Get minimum and maximum values per gene and tissue:
min.max <- apply(exprs(eset),
1,
function(x){
min <- tapply(x,
INDEX = pData(eset)$tissue,
FUN = function(y){
return(c(min = min(y),
max = max(y)))
}
)
}
)
### Difference between minimum of one tissue and maximum of the other tissue must be at least 1 (two-fold) (this way I would get elt-2, for example).
gonad <- names(min.max)[sapply(min.max,
function(x){
x$gonad["min"] - x$intestine["max"] > 1
})]
length(gonad)
## 5494
is.element(c("pie-1", "mex-5"), gonad)
## TRUE TRUE
intestine <- names(min.max)[sapply(min.max,
function(x){
x$intestine["min"] - x$gonad["max"] > 1
})]
length(intestine)
## 1418
is.element("elt-2", intestine)
## TRUE
## Write out tables with tissue specific genes and sample-wise FPKM values:
write.table(exprs(eset)[gonad, ],
col.names = NA,
sep = "\t",
quote = FALSE,
file = "Results/FPKM_gonad_specific_genes.txt")
write.table(exprs(eset)[intestine, ],
col.names = NA,
sep = "\t",
quote = FALSE,
file = "Results/FPKM_intestine_specific_genes.txt")