-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfisher_test_2_groups.R
More file actions
67 lines (41 loc) · 1.55 KB
/
Copy pathfisher_test_2_groups.R
File metadata and controls
67 lines (41 loc) · 1.55 KB
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
63
getwd()
setwd('/media/bulk_01/users/goryu003/samples/')
ls()
CNVs_mean_84_count=read.table ("/media/bulk_01/users/goryu003/samples/CNVs_mean_84_count_convert_to_int-2.txt", as.is=T, header=T)
head(CNVs_mean_84_count)
apply(CNVs_mean_84_count,2,function(x) {any (is.na(x))})
head(CNVs_mean_84_count$CHR)
head(CNVs_mean_84_count$Gene)
head(CNVs_mean_84_count[1,3:86])
head(CNVs_mean_84_count[1,])
v=rep("S.lycopersicum",22)
v=c(v,"other")
v=c(v,rep("S.lycopersicum",17))
v=c(v,"other","other")
v=c(v,"S.lycopersicum")
v=c(v,rep("other",27))
v=c(v,rep("S.lycopersicum",12))
v=c(v,"other")
v=c(v,"S.lycopersicum")
length(v)
is.character(v)
#results=data.frame(CHR=character(), Gene=character(), F.pvalue=integer(), t.pval=integer(), stringsAsFactors=FALSE)
fact=factor(v)
for (i in 1:nrow(CNVs_mean_84_count))
{
table_with_CHR_Gene=CNVs_mean_84_count[i,]
CHR=table_with_CHR_Gene[1,1]
gene=table_with_CHR_Gene[1,2]
df=data.frame(as.character(CNVs_mean_84_count[i,3:86]),v)
colnames(df)<-c("count","type")
matrix_Fisher=table(df)
print(matrix_Fisher)
if (NROW(matrix_Fisher)>1 & NCOL (matrix_Fisher)>1)
{
Test=fisher.test(matrix_Fisher)
results=data.frame(CHR=c(CHR),Gene=c(gene),F.pvalue=Test$p.value)
write.table(results,"CNVs_mean_84_count_convert_to_int-2_F.txt",append=T,col.names=T, row.names=T)
}
}
#x=read.table("/media/bulk_01/users/goryu003/samples/CNVs_mean_84_count_lm.txt", as.is=T, header=T)
#x$F.pvalue