-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpmk-ify.R
62 lines (46 loc) · 1.55 KB
/
rpmk-ify.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
62
### Code intdended to create RPKM values from a matrix of read counts for either host or pathogen.
##
data<-file.choose()
counts
candidates = read.table( datafile,sep=",", header=TRUE, row.names=1,stringsAsFactors = FALSE, fill=TRUE,quote="")
list<-rownames(candidates)
datafile="/home/ben/workspace/timeCourse/data/actinidia/cornellGenomeModelTH-TCFrequencyMatrix.csv"
counts = read.table( datafile,sep=",", header=TRUE, row.names=1,stringsAsFactors = FALSE )
lengthfile<-"/home/ben/workspace/models/cornell/cornellGeneLengths.csv"
lengthfile<-"/home/ben/workspace/timeCourse/data/psa/NZv13invitro.csv"
lengths= read.table( lengthfile,sep=",", header=FALSE, row.names=1,stringsAsFactors = FALSE ,fill=TRUE, quote="")
lengths[,1]
design <- getDataRange(counts,72,72,"psa")
design
listdesign <- as.list(t(design[,3:5]))
listdesign<-unlist(listdesign)
listdesign
counts<-counts[,listdesign]
counts
sizes<-colSums(counts)
sizes
d<-DGEList(counts=as.matrix(counts),lib.size=sizes)
d
d$genes$Length<-lengths[,1]
wibble<-rpkm(d)
dim(wibble)
head(wibble)
max(wibble)
listlist<-unlist(as.list(wibble))
breaklist<-seq(0,1000,5)
breaklist
fac<-factor(cut(listlist,breaks=breaklist))
#Tabulate and turn into data.frame
xout <- as.data.frame(table(fac))
xout
scatterplot(Freq~fac, data=xout,smoother=loessLine)
chisq.test(table(fac))
?chisq.test
#Add cumFreq and proportions
#xout <- transform(xout, cumFreq = cumsum(Freq), relative = prop.table(Freq))
xout
attach(mtcars)
plot(wt, mpg, main="Scatterplot Example", xlab="Car Weight ", ylab="Miles Per Gallon ", pch=19)
wt
mpg
mtcars