-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProcessPhyPro_v125_justprofiling.r
190 lines (171 loc) · 3.26 KB
/
ProcessPhyPro_v125_justprofiling.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Rscript ../ProcessPhyPro.r input profiled profiled-clustered
args<-commandArgs(TRUE)
#data <- read.table(args[1],sep='\t',header=T) # By default
# Warning messages:
# 1: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
# EOF within quoted string
# 2: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
# number of items read is not a multiple of the number of columns
data <- read.table(args[1],header=T) # Sometimes You have to use this one! For problems above ! I dont know why
# Input
# Gene Species Cluster
# AlyrAL1G19310 Aly 13296
# AlyrAL1G19350 Aly 75
out <- table(data$Cluster,data$Species) # This function is like countifs in excel, super.
# Make you result by species order
# Plants
# 150 Genomes (Actually 148)
# Two species do not have a node
myorder <- c(
'pmu',
'ppe',
'pbr',
'Mald',
'Rchi',
'fve',
'roc',
'Dryd',
'Tori',
'Pand',
'Mnot',
'Zjuj',
'csa',
'cme',
'cla',
'Cuma',
'Datg',
'Begf',
'vra',
'van',
'pvu',
'gma',
'cca',
'tpr',
'mtr',
'car',
'lja',
'Anan',
'Lang',
'adu',
'Bpen',
'Cgla',
'Cill',
'Qrob',
'cru',
'Csat',
'Alyr',
'ath',
'Bost',
'Lmey',
'bol',
'bnp',
'bra',
'spa',
'thh',
'tsa',
'Alp',
'aar',
'cgy',
'tha',
'cpa',
'Goba',
'Ghir',
'gra',
'Dzib',
'tca',
'Cmax',
'csi',
'Xsor',
'mes',
'rco',
'ptr',
'lus',
'egr',
'Pgra',
'spe',
'sly',
'stu',
'Caba',
'Cach',
'can',
'pax',
'Inil',
'Cuca',
'coc',
'sin',
'mgu',
'Oeur',
'Lsat',
'HanX',
'dca',
'ach',
'Aeri',
'Cqui',
'bvu',
'Ahyp',
'Mole',
'Kalf',
'vvi',
'nnu',
'Psom',
'Mcor',
'Aqco',
'sbi',
'Sacc',
'Zmay',
'sit',
'Sevi',
'Ecru',
'oth',
'ogl',
'osa',
'oru',
'Opun',
'lpe',
'Trdc',
'HORV',
'bdi',
'aco',
'mac',
'egu',
'Pdac',
'peq',
'Ashe',
'Aoff',
'Xvis',
'spo',
'zom',
'Peam',
'CKAN',
'Lchi',
'atr',
'Nymp')
# In case, you miss species
order <- match(colnames(out),myorder)
new <- rbind(order, out)
new2 <- new[,order(new[1,])]
new3 <-new2[-1,]
#out <- out[,myorder]
# Let's control Cluster Sizes
new3 <- as.data.frame(new3)
new3$Size <- rowSums(new3)
# MergedBlocks-150Genomes_del_Ebre_Csin_Aran_Tksa_2cols.sim-Info has 144 genomes
# new3 <- subset(new3,Size > 500, select=c(-145)) # NOTE here!! Your actual number of species +1
#new3 <- subset(new3,Size > 100 & Size < 120, select=c(-145)) # NOTE here!! Your actual number of species +1
#new3 <- subset(new3,Size > 2, select=c(-142)) # NOTE here!! Your actual number of species +1
#size > 1 :all clusters
# Let's try different sizes
# cluster all sizes
# new3 <- subset(new3,Size >1, select=c(-145))
# cluster size over 3
# new3 <- subset(new3,Size >3, select=c(-145))
# cluster size over 9
new3 <- subset(new3,Size >0, select=-c(ncol(new3)))
# MergedBlocks-150Genomes_del_Ebre_Csin_Aran_Tksa_2cols.sim-Info has 144 genomes
write.table(new3,args[2],col.names =NA,quote=F) # export output
# Clusters are profiled now, you could stop here, because to cluster them is a different story.
# Output sample
# Aly ath atr can csi dca Ebr hel Lsa osa oth sly Tar TKS vvi
# 1 28 28 0 65 53 43 0 59 67 25 17 59 112 9 84
# 2 7 3 11 175 17 9 0 5 19 44 1 28 100 6 13
# 3 36 62 15 16 18 12 0 39 22 36 5 14 48 3 32