... | ... |
@@ -2,7 +2,7 @@ Package: EventPointer |
2 | 2 |
Type: Package |
3 | 3 |
Title: An effective identification of alternative splicing events |
4 | 4 |
using junction arrays and RNA-Seq data |
5 |
-Version: 1.5.1 |
|
5 |
+Version: 1.99.1 |
|
6 | 6 |
Author: Juan Pablo Romero, Juan Ferrer-Bonsoms, Ander Muniategui, Fernando Carazo, Ander Aramburu, Angel Rubio |
7 | 7 |
Maintainer: Juan Pablo Romero <jpromero@ceit.es> |
8 | 8 |
Description: EventPointer is an R package to identify alternative splicing events |
... | ... |
@@ -54,7 +54,7 @@ Suggests: |
54 | 54 |
License: Artistic-2.0 |
55 | 55 |
LazyData: true |
56 | 56 |
RoxygenNote: 6.1.0 |
57 |
-biocViews: AlternativeSplicing, DifferentialSplicing, mRNAMicroarray, RNASeq, Transcription, Sequencing |
|
57 |
+biocViews: AlternativeSplicing, DifferentialSplicing, mRNAMicroarray, RNASeq, Transcription, Sequencing, TimeCourse |
|
58 | 58 |
VignetteBuilder: knitr |
59 | 59 |
Url: https://github.com/jpromeror/EventPointer |
60 | 60 |
BugReports: https://github.com/jpromeror/EventPointer/issues |
... | ... |
@@ -1,21 +1,22 @@ |
1 | 1 |
#' EventPointer Internal Functions |
2 | 2 |
#' |
3 |
-#' Internal functions used by EventPointer in the different |
|
3 |
+#' Internal functions used by EventPointer in the different |
|
4 | 4 |
#' steps of the algorithm |
5 | 5 |
#' |
6 | 6 |
#' @keywords internal |
7 | 7 |
#' @name InternalFunctions |
8 |
-#' @return Internal outputs |
|
9 |
-#' |
|
8 |
+#' @return Internal outputs |
|
9 |
+#' |
|
10 | 10 |
#' |
11 | 11 |
NULL |
12 | 12 |
|
13 | 13 |
#' @rdname InternalFunctions |
14 |
-annotateEvents <- function(Events, PSR_Gene, Junc_Gene, Gxx) { |
|
15 |
- |
|
14 |
+annotateEvents <- function(Events, PSR_Gene, |
|
15 |
+ Junc_Gene, Gxx) { |
|
16 | 16 |
GeneName <- Gxx |
17 | 17 |
ENSGID <- Gxx |
18 |
- Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, "Chr"])) |
|
18 |
+ Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, |
|
19 |
+ "Chr"])) |
|
19 | 20 |
Result <- vector("list") |
20 | 21 |
Flat <- vector("list") |
21 | 22 |
mm <- 0 |
... | ... |
@@ -31,192 +32,266 @@ annotateEvents <- function(Events, PSR_Gene, Junc_Gene, Gxx) { |
31 | 32 |
PSR_Ref <- c() |
32 | 33 |
Junc_Ref <- c() |
33 | 34 |
|
34 |
- ExonsP1 <- which(Events[[ii]]$P1[, "Type"] == "E") |
|
35 |
- JunctionsP1 <- which(Events[[ii]]$P1[, "Type"] == "J") |
|
35 |
+ ExonsP1 <- which(Events[[ii]]$P1[, |
|
36 |
+ "Type"] == "E") |
|
37 |
+ JunctionsP1 <- which(Events[[ii]]$P1[, |
|
38 |
+ "Type"] == "J") |
|
36 | 39 |
|
37 | 40 |
if (length(ExonsP1) > 0) { |
38 |
- EPP1 <- Events[[ii]]$P1[ExonsP1, ] |
|
39 |
- PSR_P1 <- sapply(seq_len(nrow(EPP1)), function(x) { |
|
40 |
- which(as.numeric(PSR_Gene[, "Start"]) >= as.numeric(EPP1[x, "Start"]) & |
|
41 |
- as.numeric(PSR_Gene[, "Stop"]) <= as.numeric(EPP1[x, "End"])) |
|
42 |
- }) |
|
43 |
- PSR_P1 <- PSR_Gene[unlist(PSR_P1), 1] |
|
44 |
- |
|
41 |
+ EPP1 <- Events[[ii]]$P1[ExonsP1, |
|
42 |
+ ] |
|
43 |
+ PSR_P1 <- sapply(seq_len(nrow(EPP1)), |
|
44 |
+ function(x) { |
|
45 |
+ which(as.numeric(PSR_Gene[, |
|
46 |
+ "Start"]) >= as.numeric(EPP1[x, |
|
47 |
+ "Start"]) & as.numeric(PSR_Gene[, |
|
48 |
+ "Stop"]) <= as.numeric(EPP1[x, |
|
49 |
+ "End"])) |
|
50 |
+ }) |
|
51 |
+ PSR_P1 <- PSR_Gene[unlist(PSR_P1), |
|
52 |
+ 1] |
|
45 | 53 |
} |
46 | 54 |
|
47 | 55 |
if (length(JunctionsP1) > 0) { |
48 |
- JPP1 <- Events[[ii]]$P1[JunctionsP1, ] |
|
49 |
- Junc_P1 <- sapply(seq_len(nrow(JPP1)), function(x) { |
|
50 |
- which(as.numeric(Junc_Gene[, "Start"]) == as.numeric(JPP1[x, "Start"]) & |
|
51 |
- as.numeric(Junc_Gene[, "Stop"]) == as.numeric(JPP1[x, "End"])) |
|
52 |
- }) |
|
53 |
- Junc_P1 <- Junc_Gene[unlist(Junc_P1), 1] |
|
54 |
- } |
|
55 |
- |
|
56 |
- |
|
57 |
- ExonsP2 <- which(Events[[ii]]$P2[, "Type"] == "E") |
|
58 |
- JunctionsP2 <- which(Events[[ii]]$P2[, "Type"] == "J") |
|
56 |
+ JPP1 <- Events[[ii]]$P1[JunctionsP1, |
|
57 |
+ ] |
|
58 |
+ Junc_P1 <- sapply(seq_len(nrow(JPP1)), |
|
59 |
+ function(x) { |
|
60 |
+ which(as.numeric(Junc_Gene[, |
|
61 |
+ "Start"]) == as.numeric(JPP1[x, |
|
62 |
+ "Start"]) & as.numeric(Junc_Gene[, |
|
63 |
+ "Stop"]) == as.numeric(JPP1[x, |
|
64 |
+ "End"])) |
|
65 |
+ }) |
|
66 |
+ Junc_P1 <- Junc_Gene[unlist(Junc_P1), |
|
67 |
+ 1] |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ |
|
71 |
+ ExonsP2 <- which(Events[[ii]]$P2[, |
|
72 |
+ "Type"] == "E") |
|
73 |
+ JunctionsP2 <- which(Events[[ii]]$P2[, |
|
74 |
+ "Type"] == "J") |
|
59 | 75 |
|
60 | 76 |
if (length(ExonsP2) > 0) { |
61 |
- EPP2 <- Events[[ii]]$P2[ExonsP2, ] |
|
62 |
- PSR_P2 <- sapply(seq_len(nrow(EPP2)), function(x) { |
|
63 |
- which(as.numeric(PSR_Gene[, "Start"]) >= as.numeric(EPP2[x, "Start"]) & |
|
64 |
- as.numeric(PSR_Gene[, "Stop"]) <= as.numeric(EPP2[x, "End"])) |
|
65 |
- }) |
|
66 |
- PSR_P2 <- PSR_Gene[unlist(PSR_P2), 1] |
|
67 |
- |
|
77 |
+ EPP2 <- Events[[ii]]$P2[ExonsP2, |
|
78 |
+ ] |
|
79 |
+ PSR_P2 <- sapply(seq_len(nrow(EPP2)), |
|
80 |
+ function(x) { |
|
81 |
+ which(as.numeric(PSR_Gene[, |
|
82 |
+ "Start"]) >= as.numeric(EPP2[x, |
|
83 |
+ "Start"]) & as.numeric(PSR_Gene[, |
|
84 |
+ "Stop"]) <= as.numeric(EPP2[x, |
|
85 |
+ "End"])) |
|
86 |
+ }) |
|
87 |
+ PSR_P2 <- PSR_Gene[unlist(PSR_P2), |
|
88 |
+ 1] |
|
68 | 89 |
} |
69 | 90 |
|
70 | 91 |
if (length(JunctionsP2) > 0) { |
71 |
- JPP2 <- Events[[ii]]$P2[JunctionsP2, ] |
|
72 |
- Junc_P2 <- sapply(seq_len(nrow(JPP2)), function(x) { |
|
73 |
- which(as.numeric(Junc_Gene[, "Start"]) == as.numeric(JPP2[x, "Start"]) & |
|
74 |
- as.numeric(Junc_Gene[, "Stop"]) == as.numeric(JPP2[x, "End"])) |
|
75 |
- }) |
|
76 |
- Junc_P2 <- Junc_Gene[unlist(Junc_P2), 1] |
|
77 |
- } |
|
78 |
- |
|
79 |
- |
|
80 |
- ExonsRef <- which(Events[[ii]]$Ref[, "Type"] == "E") |
|
81 |
- JunctionsRef <- which(Events[[ii]]$Ref[, "Type"] == "J") |
|
92 |
+ JPP2 <- Events[[ii]]$P2[JunctionsP2, |
|
93 |
+ ] |
|
94 |
+ Junc_P2 <- sapply(seq_len(nrow(JPP2)), |
|
95 |
+ function(x) { |
|
96 |
+ which(as.numeric(Junc_Gene[, |
|
97 |
+ "Start"]) == as.numeric(JPP2[x, |
|
98 |
+ "Start"]) & as.numeric(Junc_Gene[, |
|
99 |
+ "Stop"]) == as.numeric(JPP2[x, |
|
100 |
+ "End"])) |
|
101 |
+ }) |
|
102 |
+ Junc_P2 <- Junc_Gene[unlist(Junc_P2), |
|
103 |
+ 1] |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ |
|
107 |
+ ExonsRef <- which(Events[[ii]]$Ref[, |
|
108 |
+ "Type"] == "E") |
|
109 |
+ JunctionsRef <- which(Events[[ii]]$Ref[, |
|
110 |
+ "Type"] == "J") |
|
82 | 111 |
|
83 | 112 |
if (length(ExonsRef) > 0) { |
84 |
- EPRef <- Events[[ii]]$Ref[ExonsRef, ] |
|
85 |
- PSR_Ref <- sapply(seq_len(nrow(EPRef)), function(x) { |
|
86 |
- which(as.numeric(PSR_Gene[, "Start"]) >= as.numeric(EPRef[x, "Start"]) & |
|
87 |
- as.numeric(PSR_Gene[, "Stop"]) <= as.numeric(EPRef[x, "End"])) |
|
88 |
- }) |
|
89 |
- PSR_Ref <- PSR_Gene[unlist(PSR_Ref), 1] |
|
90 |
- |
|
113 |
+ EPRef <- Events[[ii]]$Ref[ExonsRef, |
|
114 |
+ ] |
|
115 |
+ PSR_Ref <- sapply(seq_len(nrow(EPRef)), |
|
116 |
+ function(x) { |
|
117 |
+ which(as.numeric(PSR_Gene[, |
|
118 |
+ "Start"]) >= as.numeric(EPRef[x, |
|
119 |
+ "Start"]) & as.numeric(PSR_Gene[, |
|
120 |
+ "Stop"]) <= as.numeric(EPRef[x, |
|
121 |
+ "End"])) |
|
122 |
+ }) |
|
123 |
+ PSR_Ref <- PSR_Gene[unlist(PSR_Ref), |
|
124 |
+ 1] |
|
91 | 125 |
} |
92 | 126 |
|
93 | 127 |
if (length(JunctionsRef) > 0) { |
94 |
- JPRef <- Events[[ii]]$Ref[JunctionsRef, ] |
|
95 |
- Junc_Ref <- sapply(seq_len(nrow(JPRef)), function(x) { |
|
96 |
- which(as.numeric(Junc_Gene[, "Start"]) == as.numeric(JPRef[x, "Start"]) & |
|
97 |
- as.numeric(Junc_Gene[, "Stop"]) == as.numeric(JPRef[x, "End"])) |
|
98 |
- }) |
|
99 |
- Junc_Ref <- Junc_Gene[unlist(Junc_Ref), 1] |
|
100 |
- } |
|
101 |
- |
|
102 |
- |
|
103 |
- # PSR_P2<-sapply(1:nrow(Events[[ii]]$P2),function(x){which(as.numeric(PSR_Gene[,'Start'])>=as.numeric(Events[[ii]]$P2[x,'Start']) |
|
104 |
- # & as.numeric(PSR_Gene[,'Stop'])<=as.numeric(Events[[ii]]$P2[x,'End']))}) |
|
105 |
- # PSR_P2<-PSR_Gene[unlist(PSR_P2),6] |
|
106 |
- # Junc_P2<-sapply(1:nrow(Events[[ii]]$P2),function(x){which(as.numeric(Junc_Gene[,'Start'])==as.numeric(Events[[ii]]$P2[x,'Start']) |
|
107 |
- # & as.numeric(Junc_Gene[,'Stop'])==as.numeric(Events[[ii]]$P2[x,'End']))}) |
|
108 |
- # Junc_P2<-Junc_Gene[unlist(Junc_P2),1] |
|
109 |
- # PSR_Ref<-sapply(1:nrow(Events[[ii]]$Ref),function(x){which(as.numeric(PSR_Gene[,'Start'])>=as.numeric(Events[[ii]]$Ref[x,'Start']) |
|
110 |
- # & as.numeric(PSR_Gene[,'Stop'])<=as.numeric(Events[[ii]]$Ref[x,'End']))}) |
|
111 |
- # PSR_Ref<-PSR_Gene[unlist(PSR_Ref),6] |
|
112 |
- # Junc_Ref<-sapply(1:nrow(Events[[ii]]$Ref),function(x){which(as.numeric(Junc_Gene[,'Start'])==as.numeric(Events[[ii]]$Ref[x,'Start']) |
|
113 |
- # & as.numeric(Junc_Gene[,'Stop'])==as.numeric(Events[[ii]]$Ref[x,'End']))}) |
|
114 |
- # Junc_Ref<-Junc_Gene[unlist(Junc_Ref),1] |
|
115 |
- |
|
116 |
- |
|
117 |
- |
|
118 |
- |
|
119 |
- Events[[ii]]$Probes_P1 <- c(PSR_P1, Junc_P1) |
|
120 |
- Events[[ii]]$Probes_P2 <- c(PSR_P2, Junc_P2) |
|
121 |
- Events[[ii]]$Probes_Ref <- c(PSR_Ref, Junc_Ref) |
|
122 |
- |
|
123 |
- if (length(Events[[ii]]$Probes_P1) > 0 & length(Events[[ii]]$Probes_P2) > |
|
124 |
- 0 & length(Events[[ii]]$Probes_Ref) > 0) { |
|
128 |
+ JPRef <- Events[[ii]]$Ref[JunctionsRef, |
|
129 |
+ ] |
|
130 |
+ Junc_Ref <- sapply(seq_len(nrow(JPRef)), |
|
131 |
+ function(x) { |
|
132 |
+ which(as.numeric(Junc_Gene[, |
|
133 |
+ "Start"]) == as.numeric(JPRef[x, |
|
134 |
+ "Start"]) & as.numeric(Junc_Gene[, |
|
135 |
+ "Stop"]) == as.numeric(JPRef[x, |
|
136 |
+ "End"])) |
|
137 |
+ }) |
|
138 |
+ Junc_Ref <- Junc_Gene[unlist(Junc_Ref), |
|
139 |
+ 1] |
|
140 |
+ } |
|
141 |
+ |
|
142 |
+ |
|
143 |
+ Events[[ii]]$Probes_P1 <- c(PSR_P1, |
|
144 |
+ Junc_P1) |
|
145 |
+ Events[[ii]]$Probes_P2 <- c(PSR_P2, |
|
146 |
+ Junc_P2) |
|
147 |
+ Events[[ii]]$Probes_Ref <- c(PSR_Ref, |
|
148 |
+ Junc_Ref) |
|
149 |
+ |
|
150 |
+ if (length(Events[[ii]]$Probes_P1) > |
|
151 |
+ 0 & length(Events[[ii]]$Probes_P2) > |
|
152 |
+ 0 & length(Events[[ii]]$Probes_Ref) > |
|
153 |
+ 0) { |
|
125 | 154 |
mm <- mm + 1 |
126 | 155 |
|
127 | 156 |
EventNumber <- ii |
128 | 157 |
|
129 | 158 |
EventType <- Events[[ii]]$Type |
130 | 159 |
|
131 |
- Positions <- rbind(Events[[ii]]$P1, Events[[ii]]$P2)[, 4:5] |
|
132 |
- Start <- as.numeric(Positions[, 1]) |
|
133 |
- End <- as.numeric(Positions[, 2]) |
|
134 |
- Start <- Start[which(Start != 0)] |
|
160 |
+ Positions <- rbind(Events[[ii]]$P1, |
|
161 |
+ Events[[ii]]$P2)[, 4:5] |
|
162 |
+ Start <- as.numeric(Positions[, |
|
163 |
+ 1]) |
|
164 |
+ End <- as.numeric(Positions[, |
|
165 |
+ 2]) |
|
166 |
+ Start <- Start[which(Start != |
|
167 |
+ 0)] |
|
135 | 168 |
End <- End[which(End != 0)] |
136 | 169 |
|
137 | 170 |
# browser() |
138 | 171 |
minGPos <- min(Start) |
139 | 172 |
maxGPos <- max(End) |
140 |
- GPos <- paste(Chrom, ":", minGPos, "-", maxGPos, sep = "") |
|
173 |
+ GPos <- paste(Chrom, ":", minGPos, |
|
174 |
+ "-", maxGPos, sep = "") |
|
141 | 175 |
|
142 |
- CP1s <- which(Events[[ii]]$P1[, 1] == "S") |
|
143 |
- CP1e <- which(Events[[ii]]$P1[, 2] == "E") |
|
176 |
+ CP1s <- which(Events[[ii]]$P1[, |
|
177 |
+ 1] == "S") |
|
178 |
+ CP1e <- which(Events[[ii]]$P1[, |
|
179 |
+ 2] == "E") |
|
144 | 180 |
|
145 |
- if (length(CP1s) > 0 | length(CP1e) > 0) { |
|
181 |
+ if (length(CP1s) > 0 | length(CP1e) > |
|
182 |
+ 0) { |
|
146 | 183 |
CC <- c(CP1s, CP1e) |
147 |
- Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, ] |
|
184 |
+ Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, |
|
185 |
+ ] |
|
148 | 186 |
} |
149 | 187 |
|
150 |
- PS1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 1])) |
|
151 |
- PE1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 2])) |
|
152 |
- Path1 <- as.matrix(cbind(PS1, PE1)) |
|
153 |
- Path1 <- Path1[order(Path1[, 1], Path1[, 2]), , drop = FALSE] |
|
154 |
- |
|
155 |
- CP2s <- which(Events[[ii]]$P2[, 1] == "S") |
|
156 |
- CP2e <- which(Events[[ii]]$P2[, 2] == "E") |
|
157 |
- |
|
158 |
- if (length(CP2s) > 0 | length(CP2e) > 0) { |
|
188 |
+ PS1 <- as.numeric(gsub(".[ab]", |
|
189 |
+ "", Events[[ii]]$P1[, 1])) |
|
190 |
+ PE1 <- as.numeric(gsub(".[ab]", |
|
191 |
+ "", Events[[ii]]$P1[, 2])) |
|
192 |
+ Path1 <- as.matrix(cbind(PS1, |
|
193 |
+ PE1)) |
|
194 |
+ Path1 <- Path1[order(Path1[, |
|
195 |
+ 1], Path1[, 2]), , drop = FALSE] |
|
196 |
+ |
|
197 |
+ CP2s <- which(Events[[ii]]$P2[, |
|
198 |
+ 1] == "S") |
|
199 |
+ CP2e <- which(Events[[ii]]$P2[, |
|
200 |
+ 2] == "E") |
|
201 |
+ |
|
202 |
+ if (length(CP2s) > 0 | length(CP2e) > |
|
203 |
+ 0) { |
|
159 | 204 |
CC <- c(CP2s, CP2e) |
160 |
- Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, ] |
|
205 |
+ Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, |
|
206 |
+ ] |
|
161 | 207 |
} |
162 | 208 |
|
163 |
- PS2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 1])) |
|
164 |
- PE2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 2])) |
|
165 |
- Path2 <- as.matrix(cbind(PS2, PE2)) |
|
166 |
- Path2 <- Path2[order(Path2[, 1], Path2[, 2]), , drop = FALSE] |
|
167 |
- |
|
168 |
- CPRs <- which(Events[[ii]]$Ref[, 1] == "S") |
|
169 |
- CPRe <- which(Events[[ii]]$Ref[, 2] == "E") |
|
170 |
- |
|
171 |
- if (length(CPRs) > 0 | length(CPRe) > 0) { |
|
209 |
+ PS2 <- as.numeric(gsub(".[ab]", |
|
210 |
+ "", Events[[ii]]$P2[, 1])) |
|
211 |
+ PE2 <- as.numeric(gsub(".[ab]", |
|
212 |
+ "", Events[[ii]]$P2[, 2])) |
|
213 |
+ Path2 <- as.matrix(cbind(PS2, |
|
214 |
+ PE2)) |
|
215 |
+ Path2 <- Path2[order(Path2[, |
|
216 |
+ 1], Path2[, 2]), , drop = FALSE] |
|
217 |
+ |
|
218 |
+ CPRs <- which(Events[[ii]]$Ref[, |
|
219 |
+ 1] == "S") |
|
220 |
+ CPRe <- which(Events[[ii]]$Ref[, |
|
221 |
+ 2] == "E") |
|
222 |
+ |
|
223 |
+ if (length(CPRs) > 0 | length(CPRe) > |
|
224 |
+ 0) { |
|
172 | 225 |
CC <- c(CPRs, CPRe) |
173 |
- Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, ] |
|
226 |
+ Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, |
|
227 |
+ ] |
|
174 | 228 |
} |
175 | 229 |
|
176 |
- PSR <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 1])) |
|
177 |
- PER <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 2])) |
|
178 |
- PathR <- as.matrix(cbind(PSR, PER)) |
|
179 |
- PathR <- PathR[order(PathR[, 1], PathR[, 2]), , drop = FALSE] |
|
180 |
- |
|
181 |
- |
|
182 |
- Path1 <- paste(Path1[, 1], "-", Path1[, 2], sep = "", collapse = ",") |
|
183 |
- Path2 <- paste(Path2[, 1], "-", Path2[, 2], sep = "", collapse = ",") |
|
184 |
- PathR <- paste(PathR[, 1], "-", PathR[, 2], sep = "", collapse = ",") |
|
185 |
- |
|
186 |
- ProbesP1 <- paste(Events[[ii]]$Probes_P1, collapse = ",") |
|
187 |
- ProbesP2 <- paste(Events[[ii]]$Probes_P2, collapse = ",") |
|
188 |
- ProbesR <- paste(Events[[ii]]$Probes_Ref, collapse = ",") |
|
189 |
- |
|
190 |
- NEv <- data.frame(GeneName, ENSGID, EventNumber, EventType, GPos, Path1, |
|
191 |
- Path2, PathR, ProbesP1, ProbesP2, ProbesR, stringsAsFactors = FALSE) |
|
230 |
+ PSR <- as.numeric(gsub(".[ab]", |
|
231 |
+ "", Events[[ii]]$Ref[, 1])) |
|
232 |
+ PER <- as.numeric(gsub(".[ab]", |
|
233 |
+ "", Events[[ii]]$Ref[, 2])) |
|
234 |
+ PathR <- as.matrix(cbind(PSR, |
|
235 |
+ PER)) |
|
236 |
+ PathR <- PathR[order(PathR[, |
|
237 |
+ 1], PathR[, 2]), , drop = FALSE] |
|
238 |
+ |
|
239 |
+ |
|
240 |
+ Path1 <- paste(Path1[, 1], "-", |
|
241 |
+ Path1[, 2], sep = "", collapse = ",") |
|
242 |
+ Path2 <- paste(Path2[, 1], "-", |
|
243 |
+ Path2[, 2], sep = "", collapse = ",") |
|
244 |
+ PathR <- paste(PathR[, 1], "-", |
|
245 |
+ PathR[, 2], sep = "", collapse = ",") |
|
246 |
+ |
|
247 |
+ ProbesP1 <- paste(Events[[ii]]$Probes_P1, |
|
248 |
+ collapse = ",") |
|
249 |
+ ProbesP2 <- paste(Events[[ii]]$Probes_P2, |
|
250 |
+ collapse = ",") |
|
251 |
+ ProbesR <- paste(Events[[ii]]$Probes_Ref, |
|
252 |
+ collapse = ",") |
|
253 |
+ |
|
254 |
+ NEv <- data.frame(GeneName, ENSGID, |
|
255 |
+ EventNumber, EventType, GPos, |
|
256 |
+ Path1, Path2, PathR, ProbesP1, |
|
257 |
+ ProbesP2, ProbesR, stringsAsFactors = FALSE) |
|
192 | 258 |
Result[[mm]] <- NEv |
193 | 259 |
|
194 | 260 |
|
195 | 261 |
Tprobes <- rbind(PSR_Gene, Junc_Gene) |
196 |
- ii.P1 <- match(Events[[ii]]$Probes_P1, Tprobes[, 1]) |
|
197 |
- ii.P2 <- match(Events[[ii]]$Probes_P2, Tprobes[, 1]) |
|
198 |
- ii.R <- match(Events[[ii]]$Probes_Ref, Tprobes[, 1]) |
|
262 |
+ ii.P1 <- match(Events[[ii]]$Probes_P1, |
|
263 |
+ Tprobes[, 1]) |
|
264 |
+ ii.P2 <- match(Events[[ii]]$Probes_P2, |
|
265 |
+ Tprobes[, 1]) |
|
266 |
+ ii.R <- match(Events[[ii]]$Probes_Ref, |
|
267 |
+ Tprobes[, 1]) |
|
199 | 268 |
|
200 | 269 |
lP1 <- length(ii.P1) |
201 | 270 |
lP2 <- length(ii.P2) |
202 | 271 |
lRef <- length(ii.R) |
203 | 272 |
|
204 |
- xRef <- rep(paste(GeneName, "_", EventNumber, "_Ref", sep = ""), lRef) |
|
205 |
- xP1 <- rep(paste(GeneName, "_", EventNumber, "_P1", sep = ""), lP1) |
|
206 |
- xP2 <- rep(paste(GeneName, "_", EventNumber, "_P2", sep = ""), lP2) |
|
207 |
- xTot <- rep(paste(GeneName, "_", EventNumber, sep = ""), lP1 + lP2 + |
|
273 |
+ xRef <- rep(paste(GeneName, "_", |
|
274 |
+ EventNumber, "_Ref", sep = ""), |
|
208 | 275 |
lRef) |
209 |
- |
|
210 |
- AllProbes <- c(Events[[ii]]$Probes_Ref, Events[[ii]]$Probes_P1, Events[[ii]]$Probes_P2) |
|
211 |
- flat_gene <- cbind(AllProbes, Tprobes[c(ii.R, ii.P1, ii.P2), c(2, 3, |
|
212 |
- 9)], c(xRef, xP1, xP2), xTot) |
|
276 |
+ xP1 <- rep(paste(GeneName, "_", |
|
277 |
+ EventNumber, "_P1", sep = ""), |
|
278 |
+ lP1) |
|
279 |
+ xP2 <- rep(paste(GeneName, "_", |
|
280 |
+ EventNumber, "_P2", sep = ""), |
|
281 |
+ lP2) |
|
282 |
+ xTot <- rep(paste(GeneName, "_", |
|
283 |
+ EventNumber, sep = ""), lP1 + |
|
284 |
+ lP2 + lRef) |
|
285 |
+ |
|
286 |
+ AllProbes <- c(Events[[ii]]$Probes_Ref, |
|
287 |
+ Events[[ii]]$Probes_P1, Events[[ii]]$Probes_P2) |
|
288 |
+ flat_gene <- cbind(AllProbes, |
|
289 |
+ Tprobes[c(ii.R, ii.P1, ii.P2), |
|
290 |
+ c(2, 3, 9)], c(xRef, xP1, |
|
291 |
+ xP2), xTot) |
|
213 | 292 |
|
214 | 293 |
Flat[[mm]] <- flat_gene |
215 |
- |
|
216 |
- |
|
217 |
- |
|
218 | 294 |
} |
219 |
- |
|
220 | 295 |
} |
221 | 296 |
|
222 | 297 |
Result <- do.call(rbind, Result) |
... | ... |
@@ -226,22 +301,26 @@ annotateEvents <- function(Events, PSR_Gene, Junc_Gene, Gxx) { |
226 | 301 |
|
227 | 302 |
|
228 | 303 |
#' @rdname InternalFunctions |
229 |
-annotateEventsMultipath <- function(Events, PSR_Gene, Junc_Gene, Gxx, paths) { |
|
304 |
+annotateEventsMultipath <- function(Events, |
|
305 |
+ PSR_Gene, Junc_Gene, Gxx, paths) { |
|
230 | 306 |
GeneName <- Gxx |
231 | 307 |
ENSGID <- Gxx |
232 |
- Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, "Chr"])) |
|
308 |
+ Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, |
|
309 |
+ "Chr"])) |
|
233 | 310 |
Result <- vector("list") |
234 | 311 |
Flat <- vector("list") |
235 | 312 |
mm <- 0 |
236 | 313 |
|
237 | 314 |
for (ii in seq_along(Events)) { |
238 |
- |
|
239 | 315 |
for (kk in seq_len(paths)) { |
240 |
- command <- paste0("Events[[ii]]$Probes_P", kk, "<-NULL") |
|
316 |
+ command <- paste0("Events[[ii]]$Probes_P", |
|
317 |
+ kk, "<-NULL") |
|
241 | 318 |
eval(parse(text = command)) |
242 |
- command <- paste0("PSR_P", kk, "<-c()") |
|
319 |
+ command <- paste0("PSR_P", kk, |
|
320 |
+ "<-c()") |
|
243 | 321 |
eval(parse(text = command)) |
244 |
- command <- paste0("Junc_P", kk, "<-c()") |
|
322 |
+ command <- paste0("Junc_P", kk, |
|
323 |
+ "<-c()") |
|
245 | 324 |
eval(parse(text = command)) |
246 | 325 |
} |
247 | 326 |
Events[[ii]]$Probes_Ref <- NULL |
... | ... |
@@ -250,85 +329,121 @@ annotateEventsMultipath <- function(Events, PSR_Gene, Junc_Gene, Gxx, paths) { |
250 | 329 |
|
251 | 330 |
|
252 | 331 |
for (kk in seq_len(paths)) { |
253 |
- |
|
254 |
- command <- paste0("ExonsP", kk, "<-which(Events[[ii]]$P", kk, "[,'Type']=='E')") |
|
332 |
+ command <- paste0("ExonsP", kk, |
|
333 |
+ "<-which(Events[[ii]]$P", |
|
334 |
+ kk, "[,'Type']=='E')") |
|
255 | 335 |
eval(parse(text = command)) |
256 | 336 |
|
257 |
- command <- paste0("JunctionsP", kk, "<-which(Events[[ii]]$P", kk, "[,'Type']=='J')") |
|
337 |
+ command <- paste0("JunctionsP", |
|
338 |
+ kk, "<-which(Events[[ii]]$P", |
|
339 |
+ kk, "[,'Type']=='J')") |
|
258 | 340 |
eval(parse(text = command)) |
259 | 341 |
|
260 | 342 |
# ExonsP1,2,3 and JunctionP1,2,... etc |
261 | 343 |
|
262 |
- command <- paste0("a <- length(ExonsP", kk, ">0)") |
|
344 |
+ command <- paste0("a <- length(ExonsP", |
|
345 |
+ kk, ">0)") |
|
263 | 346 |
eval(parse(text = command)) |
264 | 347 |
if (a > 0) { |
265 |
- command <- paste0("EPP", kk, "<-Events[[ii]]$P", kk, "[ExonsP", kk, |
|
266 |
- ",]") |
|
348 |
+ command <- paste0("EPP", |
|
349 |
+ kk, "<-Events[[ii]]$P", |
|
350 |
+ kk, "[ExonsP", kk, ",]") |
|
267 | 351 |
eval(parse(text = command)) |
268 |
- command <- paste0("PSR_P", kk, "<-sapply(1:nrow(EPP", kk, "),function(x){which(as.numeric(PSR_Gene[,'Start'])>=as.numeric(EPP", |
|
352 |
+ command <- paste0("PSR_P", |
|
353 |
+ kk, "<-sapply(1:nrow(EPP", |
|
354 |
+ kk, "),function(x){which(as.numeric(PSR_Gene[,'Start'])>=as.numeric(EPP", |
|
269 | 355 |
kk, "[x,'Start']) & as.numeric(PSR_Gene[,'Stop'])<=as.numeric(EPP", |
270 | 356 |
kk, "[x,'End']))})") |
271 | 357 |
eval(parse(text = command)) |
272 |
- command <- paste0("PSR_P", kk, "<-PSR_Gene[unlist(PSR_P", kk, "),1]") |
|
358 |
+ command <- paste0("PSR_P", |
|
359 |
+ kk, "<-PSR_Gene[unlist(PSR_P", |
|
360 |
+ kk, "),1]") |
|
273 | 361 |
eval(parse(text = command)) |
274 | 362 |
} |
275 | 363 |
|
276 |
- command <- paste0("a <- length(JunctionsP", kk, ">0)") |
|
364 |
+ command <- paste0("a <- length(JunctionsP", |
|
365 |
+ kk, ">0)") |
|
277 | 366 |
eval(parse(text = command)) |
278 | 367 |
if (a > 0) { |
279 |
- command <- paste0("JPP", kk, "<-Events[[ii]]$P", kk, "[JunctionsP", |
|
280 |
- kk, ",]") |
|
368 |
+ command <- paste0("JPP", |
|
369 |
+ kk, "<-Events[[ii]]$P", |
|
370 |
+ kk, "[JunctionsP", kk, |
|
371 |
+ ",]") |
|
281 | 372 |
eval(parse(text = command)) |
282 |
- command <- paste0("Junc_P", kk, "<-sapply(1:nrow(JPP", kk, "),function(x){which(as.numeric(Junc_Gene[,'Start'])==as.numeric(JPP", |
|
373 |
+ command <- paste0("Junc_P", |
|
374 |
+ kk, "<-sapply(1:nrow(JPP", |
|
375 |
+ kk, "),function(x){which(as.numeric(Junc_Gene[,'Start'])==as.numeric(JPP", |
|
283 | 376 |
kk, "[x,'Start']) & as.numeric(Junc_Gene[,'Stop'])==as.numeric(JPP", |
284 | 377 |
kk, "[x,'End']))})") |
285 | 378 |
eval(parse(text = command)) |
286 |
- command <- paste0("Junc_P", kk, "<-Junc_Gene[unlist(Junc_P", kk, |
|
287 |
- "),1]") |
|
379 |
+ command <- paste0("Junc_P", |
|
380 |
+ kk, "<-Junc_Gene[unlist(Junc_P", |
|
381 |
+ kk, "),1]") |
|
288 | 382 |
eval(parse(text = command)) |
289 | 383 |
} |
290 | 384 |
} |
291 | 385 |
|
292 |
- ExonsRef <- which(Events[[ii]]$Ref[, "Type"] == "E") |
|
293 |
- JunctionsRef <- which(Events[[ii]]$Ref[, "Type"] == "J") |
|
386 |
+ ExonsRef <- which(Events[[ii]]$Ref[, |
|
387 |
+ "Type"] == "E") |
|
388 |
+ JunctionsRef <- which(Events[[ii]]$Ref[, |
|
389 |
+ "Type"] == "J") |
|
294 | 390 |
|
295 | 391 |
if (length(ExonsRef) > 0) { |
296 |
- EPRef <- Events[[ii]]$Ref[ExonsRef, ] |
|
297 |
- PSR_Ref <- sapply(seq_len(nrow(EPRef)), function(x) { |
|
298 |
- which(as.numeric(PSR_Gene[, "Start"]) >= as.numeric(EPRef[x, "Start"]) & |
|
299 |
- as.numeric(PSR_Gene[, "Stop"]) <= as.numeric(EPRef[x, "End"])) |
|
300 |
- }) |
|
301 |
- PSR_Ref <- PSR_Gene[unlist(PSR_Ref), 1] |
|
302 |
- |
|
392 |
+ EPRef <- Events[[ii]]$Ref[ExonsRef, |
|
393 |
+ ] |
|
394 |
+ PSR_Ref <- sapply(seq_len(nrow(EPRef)), |
|
395 |
+ function(x) { |
|
396 |
+ which(as.numeric(PSR_Gene[, |
|
397 |
+ "Start"]) >= as.numeric(EPRef[x, |
|
398 |
+ "Start"]) & as.numeric(PSR_Gene[, |
|
399 |
+ "Stop"]) <= as.numeric(EPRef[x, |
|
400 |
+ "End"])) |
|
401 |
+ }) |
|
402 |
+ PSR_Ref <- PSR_Gene[unlist(PSR_Ref), |
|
403 |
+ 1] |
|
303 | 404 |
} |
304 | 405 |
|
305 | 406 |
if (length(JunctionsRef) > 0) { |
306 |
- JPRef <- Events[[ii]]$Ref[JunctionsRef, ] |
|
307 |
- Junc_Ref <- sapply(seq_len(nrow(JPRef)), function(x) { |
|
308 |
- which(as.numeric(Junc_Gene[, "Start"]) == as.numeric(JPRef[x, "Start"]) & |
|
309 |
- as.numeric(Junc_Gene[, "Stop"]) == as.numeric(JPRef[x, "End"])) |
|
310 |
- }) |
|
311 |
- Junc_Ref <- Junc_Gene[unlist(Junc_Ref), 1] |
|
407 |
+ JPRef <- Events[[ii]]$Ref[JunctionsRef, |
|
408 |
+ ] |
|
409 |
+ Junc_Ref <- sapply(seq_len(nrow(JPRef)), |
|
410 |
+ function(x) { |
|
411 |
+ which(as.numeric(Junc_Gene[, |
|
412 |
+ "Start"]) == as.numeric(JPRef[x, |
|
413 |
+ "Start"]) & as.numeric(Junc_Gene[, |
|
414 |
+ "Stop"]) == as.numeric(JPRef[x, |
|
415 |
+ "End"])) |
|
416 |
+ }) |
|
417 |
+ Junc_Ref <- Junc_Gene[unlist(Junc_Ref), |
|
418 |
+ 1] |
|
312 | 419 |
} |
313 | 420 |
|
314 | 421 |
|
315 | 422 |
for (kk in seq_len(paths)) { |
316 |
- command <- paste0("Events[[ii]]$Probes_P", kk, "<-c(PSR_P", kk, ",Junc_P", |
|
423 |
+ command <- paste0("Events[[ii]]$Probes_P", |
|
424 |
+ kk, "<-c(PSR_P", kk, ",Junc_P", |
|
317 | 425 |
kk, ")") |
318 | 426 |
eval(parse(text = command)) |
319 | 427 |
} |
320 |
- Events[[ii]]$Probes_Ref <- c(PSR_Ref, Junc_Ref) |
|
428 |
+ Events[[ii]]$Probes_Ref <- c(PSR_Ref, |
|
429 |
+ Junc_Ref) |
|
321 | 430 |
|
322 | 431 |
|
323 |
- # only the events in which all their events are able to be measured are shown. It |
|
324 |
- # is necesary to know the number of paths of each Event |
|
325 |
- for (kk in seq_len((Events[[ii]]$NumP + 1))) { |
|
432 |
+ # only the events in which all their |
|
433 |
+ # events are able to be measured are |
|
434 |
+ # shown. It is necesary to know the |
|
435 |
+ # number of paths of each Event |
|
436 |
+ for (kk in seq_len((Events[[ii]]$NumP + |
|
437 |
+ 1))) { |
|
326 | 438 |
if (kk == 1) { |
327 |
- a <- paste0("a <- length(Events[[ii]]$Probes_P", kk, ")>0 & ") |
|
328 |
- } else if (kk == (Events[[ii]]$NumP + 1)) { |
|
439 |
+ a <- paste0("a <- length(Events[[ii]]$Probes_P", |
|
440 |
+ kk, ")>0 & ") |
|
441 |
+ } else if (kk == (Events[[ii]]$NumP + |
|
442 |
+ 1)) { |
|
329 | 443 |
a <- paste0(a, "length(Events[[ii]]$Probes_Ref)>0") |
330 | 444 |
} else { |
331 |
- a <- paste0(a, "length(Events[[ii]]$Probes_P", kk, ")>0 & ") |
|
445 |
+ a <- paste0(a, "length(Events[[ii]]$Probes_P", |
|
446 |
+ kk, ")>0 & ") |
|
332 | 447 |
} |
333 | 448 |
} |
334 | 449 |
eval(parse(text = a)) |
... | ... |
@@ -346,93 +461,131 @@ annotateEventsMultipath <- function(Events, PSR_Gene, Junc_Gene, Gxx, paths) { |
346 | 461 |
EventNumP <- Events[[ii]]$NumP |
347 | 462 |
for (kk in seq_len(EventNumP)) { |
348 | 463 |
if (kk == 1) { |
349 |
- Positions <- paste0("Positions <- rbind(Events[[ii]]$P", kk) |
|
464 |
+ Positions <- paste0("Positions <- rbind(Events[[ii]]$P", |
|
465 |
+ kk) |
|
350 | 466 |
} else if (kk == EventNumP) { |
351 |
- Positions <- paste0(Positions, ",Events[[ii]]$P", kk, ")[,4:5]") |
|
467 |
+ Positions <- paste0(Positions, |
|
468 |
+ ",Events[[ii]]$P", kk, |
|
469 |
+ ")[,4:5]") |
|
352 | 470 |
} else { |
353 |
- Positions <- paste0(Positions, ",Events[[ii]]$P", kk) |
|
471 |
+ Positions <- paste0(Positions, |
|
472 |
+ ",Events[[ii]]$P", kk) |
|
354 | 473 |
} |
355 | 474 |
} |
356 | 475 |
eval(parse(text = Positions)) |
357 | 476 |
# Positions<-rbind(Events[[ii]]$P1,Events[[ii]]$P2)[,4:5] |
358 |
- Start <- as.numeric(Positions[, 1]) |
|
359 |
- End <- as.numeric(Positions[, 2]) |
|
360 |
- Start <- Start[which(Start != 0)] |
|
477 |
+ Start <- as.numeric(Positions[, |
|
478 |
+ 1]) |
|
479 |
+ End <- as.numeric(Positions[, |
|
480 |
+ 2]) |
|
481 |
+ Start <- Start[which(Start != |
|
482 |
+ 0)] |
|
361 | 483 |
End <- End[which(End != 0)] |
362 | 484 |
|
363 | 485 |
# browser() |
364 | 486 |
minGPos <- min(Start) |
365 | 487 |
maxGPos <- max(End) |
366 |
- GPos <- paste(Chrom, ":", minGPos, "-", maxGPos, sep = "") |
|
488 |
+ GPos <- paste(Chrom, ":", minGPos, |
|
489 |
+ "-", maxGPos, sep = "") |
|
367 | 490 |
|
368 | 491 |
for (kk in seq_len(EventNumP)) { |
369 |
- command <- paste0("CP", kk, "s<-which(Events[[ii]]$P", kk, "[,1]=='S')") |
|
492 |
+ command <- paste0("CP", kk, |
|
493 |
+ "s<-which(Events[[ii]]$P", |
|
494 |
+ kk, "[,1]=='S')") |
|
370 | 495 |
eval(parse(text = command)) |
371 |
- command <- paste0("CP", kk, "e<-which(Events[[ii]]$P", kk, "[,2]=='E')") |
|
496 |
+ command <- paste0("CP", kk, |
|
497 |
+ "e<-which(Events[[ii]]$P", |
|
498 |
+ kk, "[,2]=='E')") |
|
372 | 499 |
eval(parse(text = command)) |
373 |
- a <- paste0("a<-length(CP", kk, "s)>0|length(CP", kk, "e)>0") |
|
500 |
+ a <- paste0("a<-length(CP", |
|
501 |
+ kk, "s)>0|length(CP", kk, |
|
502 |
+ "e)>0") |
|
374 | 503 |
eval(parse(text = a)) |
375 | 504 |
if (a) { |
376 |
- command <- paste0("CC<-c(CP", kk, "s,CP", kk, "e)") |
|
505 |
+ command <- paste0("CC<-c(CP", |
|
506 |
+ kk, "s,CP", kk, "e)") |
|
377 | 507 |
eval(parse(text = command)) |
378 |
- command <- paste0("Events[[ii]]$P", kk, "<-Events[[ii]]$P", kk, |
|
379 |
- "[-CC,]") |
|
508 |
+ command <- paste0("Events[[ii]]$P", |
|
509 |
+ kk, "<-Events[[ii]]$P", |
|
510 |
+ kk, "[-CC,]") |
|
380 | 511 |
eval(parse(text = command)) |
381 | 512 |
} |
382 |
- command <- paste0("PS", kk, "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
|
513 |
+ command <- paste0("PS", kk, |
|
514 |
+ "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
|
383 | 515 |
kk, "[,1]))") |
384 | 516 |
eval(parse(text = command)) |
385 |
- command <- paste0("PE", kk, "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
|
517 |
+ command <- paste0("PE", kk, |
|
518 |
+ "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
|
386 | 519 |
kk, "[,2]))") |
387 | 520 |
eval(parse(text = command)) |
388 |
- command <- paste0("Path", kk, "<-as.matrix(cbind(PS", kk, ",PE", |
|
389 |
- kk, "))") |
|
521 |
+ command <- paste0("Path", |
|
522 |
+ kk, "<-as.matrix(cbind(PS", |
|
523 |
+ kk, ",PE", kk, "))") |
|
390 | 524 |
eval(parse(text = command)) |
391 |
- command <- paste0("Path", kk, "<-Path", kk, "[order(Path", kk, "[,1],Path", |
|
392 |
- kk, "[,2]),,drop=FALSE]") |
|
525 |
+ command <- paste0("Path", |
|
526 |
+ kk, "<-Path", kk, "[order(Path", |
|
527 |
+ kk, "[,1],Path", kk, "[,2]),,drop=FALSE]") |
|
393 | 528 |
eval(parse(text = command)) |
394 | 529 |
} |
395 | 530 |
|
396 | 531 |
|
397 |
- CPRs <- which(Events[[ii]]$Ref[, 1] == "S") |
|
398 |
- CPRe <- which(Events[[ii]]$Ref[, 2] == "E") |
|
532 |
+ CPRs <- which(Events[[ii]]$Ref[, |
|
533 |
+ 1] == "S") |
|
534 |
+ CPRe <- which(Events[[ii]]$Ref[, |
|
535 |
+ 2] == "E") |
|
399 | 536 |
|
400 |
- if (length(CPRs) > 0 | length(CPRe) > 0) { |
|
537 |
+ if (length(CPRs) > 0 | length(CPRe) > |
|
538 |
+ 0) { |
|
401 | 539 |
CC <- c(CPRs, CPRe) |
402 |
- Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, ] |
|
540 |
+ Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, |
|
541 |
+ ] |
|
403 | 542 |
} |
404 | 543 |
|
405 |
- PSR <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 1])) |
|
406 |
- PER <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 2])) |
|
407 |
- PathR <- as.matrix(cbind(PSR, PER)) |
|
408 |
- PathR <- PathR[order(PathR[, 1], PathR[, 2]), , drop = FALSE] |
|
409 |
- |
|
410 |
- PathR <- paste(PathR[, 1], "-", PathR[, 2], sep = "", collapse = ",") |
|
411 |
- ProbesR <- paste(Events[[ii]]$Probes_Ref, collapse = ",") |
|
544 |
+ PSR <- as.numeric(gsub(".[ab]", |
|
545 |
+ "", Events[[ii]]$Ref[, 1])) |
|
546 |
+ PER <- as.numeric(gsub(".[ab]", |
|
547 |
+ "", Events[[ii]]$Ref[, 2])) |
|
548 |
+ PathR <- as.matrix(cbind(PSR, |
|
549 |
+ PER)) |
|
550 |
+ PathR <- PathR[order(PathR[, |
|
551 |
+ 1], PathR[, 2]), , drop = FALSE] |
|
552 |
+ |
|
553 |
+ PathR <- paste(PathR[, 1], "-", |
|
554 |
+ PathR[, 2], sep = "", collapse = ",") |
|
555 |
+ ProbesR <- paste(Events[[ii]]$Probes_Ref, |
|
556 |
+ collapse = ",") |
|
412 | 557 |
NEv <- "NEv<-data.frame(GeneName,ENSGID,EventNumber,EventType,GPos,EventNumP," |
413 | 558 |
for (kk in seq_len(paths)) { |
414 | 559 |
if (kk <= EventNumP) { |
415 |
- command <- paste0("Path", kk, "<-paste(Path", kk, "[,1],'-',Path", |
|
416 |
- kk, "[,2],sep='',collapse=',')") |
|
560 |
+ command <- paste0("Path", |
|
561 |
+ kk, "<-paste(Path", kk, |
|
562 |
+ "[,1],'-',Path", kk, |
|
563 |
+ "[,2],sep='',collapse=',')") |
|
417 | 564 |
eval(parse(text = command)) |
418 |
- command <- paste0("ProbesP", kk, "<-paste(Events[[ii]]$Probes_P", |
|
565 |
+ command <- paste0("ProbesP", |
|
566 |
+ kk, "<-paste(Events[[ii]]$Probes_P", |
|
419 | 567 |
kk, ",collapse=',')") |
420 | 568 |
eval(parse(text = command)) |
421 | 569 |
} else { |
422 |
- command <- paste0("Path", kk, "<-'-'") |
|
570 |
+ command <- paste0("Path", |
|
571 |
+ kk, "<-'-'") |
|
423 | 572 |
eval(parse(text = command)) |
424 |
- command <- paste0("ProbesP", kk, "<-'-'") |
|
573 |
+ command <- paste0("ProbesP", |
|
574 |
+ kk, "<-'-'") |
|
425 | 575 |
eval(parse(text = command)) |
426 | 576 |
} |
427 |
- NEv <- paste0(NEv, "Path", kk, ",") |
|
577 |
+ NEv <- paste0(NEv, "Path", |
|
578 |
+ kk, ",") |
|
428 | 579 |
} |
429 | 580 |
NEv <- paste0(NEv, "PathR,") |
430 | 581 |
for (kk in seq_len(paths)) { |
431 |
- NEv <- paste0(NEv, "ProbesP", kk, ",") |
|
582 |
+ NEv <- paste0(NEv, "ProbesP", |
|
583 |
+ kk, ",") |
|
432 | 584 |
} |
433 | 585 |
NEv <- paste0(NEv, "ProbesR,stringsAsFactors = FALSE)") |
434 | 586 |
eval(parse(text = NEv)) |
435 |
- # NEv<-data.frame(GeneName,ENSGID,EventNumber,EventType,GPos,Path1,Path2,PathR,ProbesP1,ProbesP2,ProbesR,stringsAsFactors |
|
587 |
+ # NEv<-data.frame(GeneName,ENSGID,EventNumber,EventType,GPos, |
|
588 |
+ # Path1,Path2,PathR,ProbesP1,ProbesP2,ProbesR,stringsAsFactors |
|
436 | 589 |
# = FALSE) |
437 | 590 |
Result[[mm]] <- NEv |
438 | 591 |
|
... | ... |
@@ -442,50 +595,64 @@ annotateEventsMultipath <- function(Events, PSR_Gene, Junc_Gene, Gxx, paths) { |
442 | 595 |
AllProbes <- "AllProbes<-c(Events[[ii]]$Probes_Ref," |
443 | 596 |
flat_gene <- "flat_gene<-cbind(AllProbes,Tprobes[c(ii.R," |
444 | 597 |
for (kk in seq_len(EventNumP)) { |
445 |
- command <- paste0("ii.P", kk, "<-match(Events[[ii]]$Probes_P", kk, |
|
446 |
- ",Tprobes[,1])") |
|
598 |
+ command <- paste0("ii.P", |
|
599 |
+ kk, "<-match(Events[[ii]]$Probes_P", |
|
600 |
+ kk, ",Tprobes[,1])") |
|
447 | 601 |
eval(parse(text = command)) |
448 |
- command <- paste0("lP", kk, "<-length(ii.P", kk, ")") |
|
602 |
+ command <- paste0("lP", kk, |
|
603 |
+ "<-length(ii.P", kk, ")") |
|
449 | 604 |
eval(parse(text = command)) |
450 |
- command <- paste0("xP", kk, "<-rep(paste(GeneName,'_',EventNumber,'_P", |
|
451 |
- kk, "',sep=''),lP", kk, ")") |
|
605 |
+ command <- paste0("xP", kk, |
|
606 |
+ "<-rep(paste(GeneName,'_',EventNumber,'_P", |
|
607 |
+ kk, "',sep=''),lP", kk, |
|
608 |
+ ")") |
|
452 | 609 |
eval(parse(text = command)) |
453 |
- xTot <- paste0(xTot, "lP", kk, "+") |
|
610 |
+ xTot <- paste0(xTot, "lP", |
|
611 |
+ kk, "+") |
|
454 | 612 |
if (kk == EventNumP) { |
455 |
- AllProbes <- paste0(AllProbes, "Events[[ii]]$Probes_P", kk, ")") |
|
456 |
- flat_gene <- paste0(flat_gene, "ii.P", kk, "),c(2,3,9)],c(xRef,") |
|
613 |
+ AllProbes <- paste0(AllProbes, |
|
614 |
+ "Events[[ii]]$Probes_P", |
|
615 |
+ kk, ")") |
|
616 |
+ flat_gene <- paste0(flat_gene, |
|
617 |
+ "ii.P", kk, "),c(2,3,9)],c(xRef,") |
|
457 | 618 |
for (zz in seq_len(EventNumP)) { |
458 | 619 |
if (zz == EventNumP) { |
459 |
- flat_gene <- paste0(flat_gene, "xP", zz, "),xTot)") |
|
620 |
+ flat_gene <- paste0(flat_gene, |
|
621 |
+ "xP", zz, "),xTot)") |
|
460 | 622 |
} else { |
461 |
- flat_gene <- paste0(flat_gene, "xP", zz, ",") |
|
623 |
+ flat_gene <- paste0(flat_gene, |
|
624 |
+ "xP", zz, ",") |
|
462 | 625 |
} |
463 |
- |
|
464 | 626 |
} |
465 | 627 |
} else { |
466 |
- AllProbes <- paste0(AllProbes, "Events[[ii]]$Probes_P", kk, ",") |
|
467 |
- flat_gene <- paste0(flat_gene, "ii.P", kk, ",") |
|
628 |
+ AllProbes <- paste0(AllProbes, |
|
629 |
+ "Events[[ii]]$Probes_P", |
|
630 |
+ kk, ",") |
|
631 |
+ flat_gene <- paste0(flat_gene, |
|
632 |
+ "ii.P", kk, ",") |
|
468 | 633 |
} |
469 | 634 |
} |
470 | 635 |
xTot <- paste0(xTot, "lRef)") |
471 | 636 |
|
472 |
- ii.R <- match(Events[[ii]]$Probes_Ref, Tprobes[, 1]) |
|
637 |
+ ii.R <- match(Events[[ii]]$Probes_Ref, |
|
638 |
+ Tprobes[, 1]) |
|
473 | 639 |
lRef <- length(ii.R) |
474 |
- xRef <- rep(paste(GeneName, "_", EventNumber, "_Ref", sep = ""), lRef) |
|
640 |
+ xRef <- rep(paste(GeneName, "_", |
|
641 |
+ EventNumber, "_Ref", sep = ""), |
|
642 |
+ lRef) |
|
475 | 643 |
|
476 | 644 |
eval(parse(text = xTot)) |
477 | 645 |
eval(parse(text = AllProbes)) |
478 | 646 |
eval(parse(text = flat_gene)) |
479 |
- # AllProbes<-c(Events[[ii]]$Probes_Ref,Events[[ii]]$Probes_P1,Events[[ii]]$Probes_P2) |
|
480 |
- # flat_gene<-cbind(AllProbes,Tprobes[c(ii.R,ii.P1,ii.P2),c(2,3,9)],c(xRef,xP1,xP2),xTot) |
|
481 |
- colnames(flat_gene) <- c("Probe_ID", "X", "Y", "Probe_Sequence", "Group_ID", |
|
482 |
- "Unit_ID") |
|
647 |
+ # AllProbes<-c(Events[[ii]]$Probes_Ref,Events[[ii]]$Probes_P1, |
|
648 |
+ # Events[[ii]]$Probes_P2) |
|
649 |
+ # flat_gene<-cbind(AllProbes,Tprobes[c(ii.R,ii.P1,ii.P2),c(2,3,9)], |
|
650 |
+ # c(xRef,xP1,xP2),xTot) |
|
651 |
+ colnames(flat_gene) <- c("Probe_ID", |
|
652 |
+ "X", "Y", "Probe_Sequence", |
|
653 |
+ "Group_ID", "Unit_ID") |
|
483 | 654 |
Flat[[mm]] <- flat_gene |
484 |
- |
|
485 |
- |
|
486 |
- |
|
487 | 655 |
} |
488 |
- |
|
489 | 656 |
} |
490 | 657 |
|
491 | 658 |
Result <- do.call(rbind, Result) |
... | ... |
@@ -498,15 +665,16 @@ annotateEventsMultipath <- function(Events, PSR_Gene, Junc_Gene, Gxx, paths) { |
498 | 665 |
AnnotateEvents_RNASeq <- function(Events) { |
499 | 666 |
Result <- vector("list", length = length(Events)) |
500 | 667 |
for (ii in seq_along(Events)) { |
501 |
- |
|
502 |
- |
|
503 | 668 |
GeneName <- as.vector(Events[[ii]]$GeneName) |
504 | 669 |
GeneID <- as.vector(Events[[ii]]$Gene) |
505 | 670 |
EventNumber <- ii |
506 |
- EventID <- paste(GeneID, "_", EventNumber, sep = "") |
|
671 |
+ EventID <- paste(GeneID, "_", EventNumber, |
|
672 |
+ sep = "") |
|
507 | 673 |
EventType <- Events[[ii]]$Type |
508 |
- Chrom <- as.vector(Events[[ii]]$P1[1, "Chr"]) |
|
509 |
- Positions <- rbind(Events[[ii]]$P1, Events[[ii]]$P2)[, 4:5] |
|
674 |
+ Chrom <- as.vector(Events[[ii]]$P1[1, |
|
675 |
+ "Chr"]) |
|
676 |
+ Positions <- rbind(Events[[ii]]$P1, |
|
677 |
+ Events[[ii]]$P2)[, 4:5] |
|
510 | 678 |
Start <- as.numeric(Positions[, 1]) |
511 | 679 |
End <- as.numeric(Positions[, 2]) |
512 | 680 |
Start <- Start[which(Start != 0)] |
... | ... |
@@ -515,87 +683,115 @@ AnnotateEvents_RNASeq <- function(Events) { |
515 | 683 |
# browser() |
516 | 684 |
minGPos <- min(Start) |
517 | 685 |
maxGPos <- max(End) |
518 |
- GPos <- paste(Chrom, ":", minGPos, "-", maxGPos, sep = "") |
|
686 |
+ GPos <- paste(Chrom, ":", minGPos, |
|
687 |
+ "-", maxGPos, sep = "") |
|
519 | 688 |
|
520 |
- CP1s <- which(Events[[ii]]$P1[, 1] == "S") |
|
521 |
- CP1e <- which(Events[[ii]]$P1[, 2] == "E") |
|
689 |
+ CP1s <- which(Events[[ii]]$P1[, 1] == |
|
690 |
+ "S") |
|
691 |
+ CP1e <- which(Events[[ii]]$P1[, 2] == |
|
692 |
+ "E") |
|
522 | 693 |
|
523 |
- if (length(CP1s) > 0 | length(CP1e) > 0) { |
|
694 |
+ if (length(CP1s) > 0 | length(CP1e) > |
|
695 |
+ 0) { |
|
524 | 696 |
CC <- c(CP1s, CP1e) |
525 |
- Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, ] |
|
697 |
+ Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, |
|
698 |
+ ] |
|
526 | 699 |
} |
527 | 700 |
|
528 |
- PS1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 1])) |
|
529 |
- PE1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 2])) |
|
701 |
+ PS1 <- as.numeric(gsub(".[ab]", "", |
|
702 |
+ Events[[ii]]$P1[, 1])) |
|
703 |
+ PE1 <- as.numeric(gsub(".[ab]", "", |
|
704 |
+ Events[[ii]]$P1[, 2])) |
|
530 | 705 |
Path1 <- as.matrix(cbind(PS1, PE1)) |
531 |
- Path1 <- Path1[order(Path1[, 1], Path1[, 2]), , drop = FALSE] |
|
706 |
+ Path1 <- Path1[order(Path1[, 1], |
|
707 |
+ Path1[, 2]), , drop = FALSE] |
|
532 | 708 |
|
533 |
- CP2s <- which(Events[[ii]]$P2[, 1] == "S") |
|
534 |
- CP2e <- which(Events[[ii]]$P2[, 2] == "E") |
|
709 |
+ CP2s <- which(Events[[ii]]$P2[, 1] == |
|
710 |
+ "S") |
|
711 |
+ CP2e <- which(Events[[ii]]$P2[, 2] == |
|
712 |
+ "E") |
|
535 | 713 |
|
536 |
- if (length(CP2s) > 0 | length(CP2e) > 0) { |
|
714 |
+ if (length(CP2s) > 0 | length(CP2e) > |
|
715 |
+ 0) { |
|
537 | 716 |
CC <- c(CP2s, CP2e) |
538 |
- Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, ] |
|
717 |
+ Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, |
|
718 |
+ ] |
|
539 | 719 |
} |
540 | 720 |
|
541 |
- PS2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 1])) |
|
542 |
- PE2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 2])) |
|
721 |
+ PS2 <- as.numeric(gsub(".[ab]", "", |
|
722 |
+ Events[[ii]]$P2[, 1])) |
|
723 |
+ PE2 <- as.numeric(gsub(".[ab]", "", |
|
724 |
+ Events[[ii]]$P2[, 2])) |
|
543 | 725 |
Path2 <- as.matrix(cbind(PS2, PE2)) |
544 |
- Path2 <- Path2[order(Path2[, 1], Path2[, 2]), , drop = FALSE] |
|
726 |
+ Path2 <- Path2[order(Path2[, 1], |
|
727 |
+ Path2[, 2]), , drop = FALSE] |
|
545 | 728 |
|
546 |
- CPRs <- which(Events[[ii]]$Ref[, 1] == "S") |
|
547 |
- CPRe <- which(Events[[ii]]$Ref[, 2] == "E") |
|
729 |
+ CPRs <- which(Events[[ii]]$Ref[, |
|
730 |
+ 1] == "S") |
|
731 |
+ CPRe <- which(Events[[ii]]$Ref[, |
|
732 |
+ 2] == "E") |
|
548 | 733 |
|
549 |
- if (length(CPRs) > 0 | length(CPRe) > 0) { |
|
734 |
+ if (length(CPRs) > 0 | length(CPRe) > |
|
735 |
+ 0) { |
|
550 | 736 |
CC <- c(CPRs, CPRe) |
551 |
- Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, ] |
|
737 |
+ Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, |
|
738 |
+ ] |
|
552 | 739 |
} |
553 | 740 |
|
554 |
- PSR <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 1])) |
|
555 |
- PER <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 2])) |
|
741 |
+ PSR <- as.numeric(gsub(".[ab]", "", |
|
742 |
+ Events[[ii]]$Ref[, 1])) |
|
743 |
+ PER <- as.numeric(gsub(".[ab]", "", |
|
744 |
+ Events[[ii]]$Ref[, 2])) |
|
556 | 745 |
PathR <- as.matrix(cbind(PSR, PER)) |
557 |
- PathR <- PathR[order(PathR[, 1], PathR[, 2]), , drop = FALSE] |
|
746 |
+ PathR <- PathR[order(PathR[, 1], |
|
747 |
+ PathR[, 2]), , drop = FALSE] |
|
558 | 748 |
|
559 | 749 |
|
560 |
- Path1 <- paste(Path1[, 1], "-", Path1[, 2], sep = "", collapse = ",") |
|
561 |
- Path2 <- paste(Path2[, 1], "-", Path2[, 2], sep = "", collapse = ",") |
|
562 |
- PathR <- paste(PathR[, 1], "-", PathR[, 2], sep = "", collapse = ",") |
|
750 |
+ Path1 <- paste(Path1[, 1], "-", Path1[, |
|
751 |
+ 2], sep = "", collapse = ",") |
|
752 |
+ Path2 <- paste(Path2[, 1], "-", Path2[, |
|
753 |
+ 2], sep = "", collapse = ",") |
|
754 |
+ PathR <- paste(PathR[, 1], "-", PathR[, |
|
755 |
+ 2], sep = "", collapse = ",") |
|
563 | 756 |
|
564 |
- NEv <- data.frame(EventID, GeneName, EventNumber, EventType, GPos, Path1, |
|
565 |
- Path2, PathR, stringsAsFactors = FALSE) |
|
757 |
+ NEv <- data.frame(EventID, GeneName, |
|
758 |
+ EventNumber, EventType, GPos, |
|
759 |
+ Path1, Path2, PathR, stringsAsFactors = FALSE) |
|
566 | 760 |
Result[[ii]] <- NEv |
567 |
- |
|
568 | 761 |
} |
569 | 762 |
|
570 | 763 |
Result <- do.call(rbind, Result) |
571 |
- colnames(Result) <- c("EventID", "Gene", "Event Number", "Event Type", "Genomic Position", |
|
764 |
+ colnames(Result) <- c("EventID", "Gene", |
|
765 |
+ "Event Number", "Event Type", "Genomic Position", |
|
572 | 766 |
"Path 1", "Path 2", "Path Reference") |
573 | 767 |
|
574 | 768 |
return(Result) |
575 |
- |
|
576 |
- |
|
577 | 769 |
} |
578 | 770 |
|
579 | 771 |
#' @rdname InternalFunctions |
580 |
-AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
|
772 |
+AnnotateEvents_RNASeq_MultiPath <- function(Events, |
|
773 |
+ paths) { |
|
774 |
+ Positions <- NULL |
|
581 | 775 |
Result <- vector("list", length = length(Events)) |
582 | 776 |
for (ii in seq_along(Events)) { |
583 |
- |
|
584 |
- |
|
585 | 777 |
GeneName <- as.vector(Events[[ii]]$GeneName) |
586 | 778 |
GeneID <- as.vector(Events[[ii]]$Gene) |
587 | 779 |
EventNumber <- ii |
588 |
- EventID <- paste(GeneID, "_", EventNumber, sep = "") |
|
780 |
+ EventID <- paste(GeneID, "_", EventNumber, |
|
781 |
+ sep = "") |
|
589 | 782 |
EventType <- Events[[ii]]$Type |
590 |
- Chrom <- as.vector(Events[[ii]]$P1[1, "Chr"]) |
|
783 |
+ Chrom <- as.vector(Events[[ii]]$P1[1, |
|
784 |
+ "Chr"]) |
|
591 | 785 |
|
592 | 786 |
EventNumP <- Events[[ii]]$NumP |
593 | 787 |
command <- "Positions<-rbind(Events[[ii]]$P1," |
594 | 788 |
for (kk in 2:EventNumP) { |
595 | 789 |
if (kk == EventNumP) { |
596 |
- command <- paste0(command, "Events[[ii]]$P", kk, ")[,4:5]") |
|
790 |
+ command <- paste0(command, |
|
791 |
+ "Events[[ii]]$P", kk, ")[,4:5]") |
|
597 | 792 |
} else { |
598 |
- command <- paste0(command, "Events[[ii]]$P", kk, ",") |
|
793 |
+ command <- paste0(command, |
|
794 |
+ "Events[[ii]]$P", kk, ",") |
|
599 | 795 |
} |
600 | 796 |
} |
601 | 797 |
eval(parse(text = command)) |
... | ... |
@@ -608,27 +804,37 @@ AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
608 | 804 |
# browser() |
609 | 805 |
minGPos <- min(Start) |
610 | 806 |
maxGPos <- max(End) |
611 |
- GPos <- paste(Chrom, ":", minGPos, "-", maxGPos, sep = "") |
|
612 |
- |
|
613 |
- # CP1s<-which(Events[[ii]]$P1[,1]=='S') CP1e<-which(Events[[ii]]$P1[,2]=='E') |
|
614 |
- # if(length(CP1s)>0|length(CP1e)>0) { CC<-c(CP1s,CP1e) |
|
615 |
- # Events[[ii]]$P1<-Events[[ii]]$P1[-CC,] } |
|
807 |
+ GPos <- paste(Chrom, ":", minGPos, |
|
808 |
+ "-", maxGPos, sep = "") |
|
809 |
+ |
|
810 |
+ # CP1s<-which(Events[[ii]]$P1[,1]=='S') |
|
811 |
+ # CP1e<-which(Events[[ii]]$P1[,2]=='E') |
|
812 |
+ # if(length(CP1s)>0|length(CP1e)>0) { |
|
813 |
+ # CC<-c(CP1s,CP1e) |
|
814 |
+ # Events[[ii]]$P1<-Events[[ii]]$P1[-CC,] |
|
815 |
+ # } |
|
616 | 816 |
# PS1<-as.numeric(gsub('.[ab]','',Events[[ii]]$P1[,1])) |
617 | 817 |
# PE1<-as.numeric(gsub('.[ab]','',Events[[ii]]$P1[,2])) |
618 | 818 |
# Path1<-as.matrix(cbind(PS1,PE1)) |
619 | 819 |
# Path1<-Path1[order(Path1[,1],Path1[,2]),,drop=FALSE] |
620 | 820 |
|
621 | 821 |
for (kk in seq_len(EventNumP)) { |
622 |
- command <- paste0("CP", kk, "s<-which(Events[[ii]]$P", kk, "[,1]=='S')") |
|
822 |
+ command <- paste0("CP", kk, "s<-which(Events[[ii]]$P", |
|
823 |
+ kk, "[,1]=='S')") |
|
623 | 824 |
eval(parse(text = command)) |
624 |
- command <- paste0("CP", kk, "e<-which(Events[[ii]]$P", kk, "[,2]=='E')") |
|
825 |
+ command <- paste0("CP", kk, "e<-which(Events[[ii]]$P", |
|
826 |
+ kk, "[,2]=='E')") |
|
625 | 827 |
eval(parse(text = command)) |
626 |
- a <- paste0("a<-length(CP", kk, "s)>0|length(CP", kk, "e)>0") |
|
828 |
+ a <- paste0("a<-length(CP", kk, |
|
829 |
+ "s)>0|length(CP", kk, "e)>0") |
|
627 | 830 |
eval(parse(text = a)) |
628 | 831 |
if (a) { |
629 |
- command <- paste0("CC<-c(CP", kk, "s,CP", kk, "e)") |
|
832 |
+ command <- paste0("CC<-c(CP", |
|
833 |
+ kk, "s,CP", kk, "e)") |
|
630 | 834 |
eval(parse(text = command)) |
631 |
- command <- paste0("Events[[ii]]$P", kk, "<-Events[[ii]]$P", kk, "[-CC,]") |
|
835 |
+ command <- paste0("Events[[ii]]$P", |
|
836 |
+ kk, "<-Events[[ii]]$P", |
|
837 |
+ kk, "[-CC,]") |
|
632 | 838 |
eval(parse(text = command)) |
633 | 839 |
} |
634 | 840 |
command <- paste0("PS", kk, "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
... | ... |
@@ -637,11 +843,13 @@ AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
637 | 843 |
command <- paste0("PE", kk, "<-as.numeric(gsub('.[ab]','',Events[[ii]]$P", |
638 | 844 |
kk, "[,2]))") |
639 | 845 |
eval(parse(text = command)) |
640 |
- command <- paste0("Path", kk, "<-as.matrix(cbind(PS", kk, ",PE", kk, |
|
641 |
- "))") |
|
846 |
+ command <- paste0("Path", kk, |
|
847 |
+ "<-as.matrix(cbind(PS", kk, |
|
848 |
+ ",PE", kk, "))") |
|
642 | 849 |
eval(parse(text = command)) |
643 |
- command <- paste0("Path", kk, "<-Path", kk, "[order(Path", kk, "[,1],Path", |
|
644 |
- kk, "[,2]),,drop=FALSE]") |
|
850 |
+ command <- paste0("Path", kk, |
|
851 |
+ "<-Path", kk, "[order(Path", |
|
852 |
+ kk, "[,1],Path", kk, "[,2]),,drop=FALSE]") |
|
645 | 853 |
eval(parse(text = command)) |
646 | 854 |
} |
647 | 855 |
|
... | ... |
@@ -650,26 +858,36 @@ AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
650 | 858 |
|
651 | 859 |
|
652 | 860 |
|
653 |
- # CP2s<-which(Events[[ii]]$P2[,1]=='S') CP2e<-which(Events[[ii]]$P2[,2]=='E') |
|
654 |
- # if(length(CP2s)>0|length(CP2e)>0) { CC<-c(CP2s,CP2e) |
|
655 |
- # Events[[ii]]$P2<-Events[[ii]]$P2[-CC,] } |
|
861 |
+ # CP2s<-which(Events[[ii]]$P2[,1]=='S') |
|
862 |
+ # CP2e<-which(Events[[ii]]$P2[,2]=='E') |
|
863 |
+ # if(length(CP2s)>0|length(CP2e)>0) { |
|
864 |
+ # CC<-c(CP2s,CP2e) |
|
865 |
+ # Events[[ii]]$P2<-Events[[ii]]$P2[-CC,] |
|
866 |
+ # } |
|
656 | 867 |
# PS2<-as.numeric(gsub('.[ab]','',Events[[ii]]$P2[,1])) |
657 | 868 |
# PE2<-as.numeric(gsub('.[ab]','',Events[[ii]]$P2[,2])) |
658 | 869 |
# Path2<-as.matrix(cbind(PS2,PE2)) |
659 | 870 |
# Path2<-Path2[order(Path2[,1],Path2[,2]),,drop=FALSE] |
660 | 871 |
|
661 |
- CPRs <- which(Events[[ii]]$Ref[, 1] == "S") |
|
662 |
- CPRe <- which(Events[[ii]]$Ref[, 2] == "E") |
|
872 |
+ CPRs <- which(Events[[ii]]$Ref[, |
|
873 |
+ 1] == "S") |
|
874 |
+ CPRe <- which(Events[[ii]]$Ref[, |
|
875 |
+ 2] == "E") |
|
663 | 876 |
|
664 |
- if (length(CPRs) > 0 | length(CPRe) > 0) { |
|
877 |
+ if (length(CPRs) > 0 | length(CPRe) > |
|
878 |
+ 0) { |
|
665 | 879 |
CC <- c(CPRs, CPRe) |
666 |
- Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, ] |
|
880 |
+ Events[[ii]]$Ref <- Events[[ii]]$Ref[-CC, |
|
881 |
+ ] |
|
667 | 882 |
} |
668 | 883 |
|
669 |
- PSR <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 1])) |
|
670 |
- PER <- as.numeric(gsub(".[ab]", "", Events[[ii]]$Ref[, 2])) |
|
884 |
+ PSR <- as.numeric(gsub(".[ab]", "", |
|
885 |
+ Events[[ii]]$Ref[, 1])) |
|
886 |
+ PER <- as.numeric(gsub(".[ab]", "", |
|
887 |
+ Events[[ii]]$Ref[, 2])) |
|
671 | 888 |
PathR <- as.matrix(cbind(PSR, PER)) |
672 |
- PathR <- PathR[order(PathR[, 1], PathR[, 2]), , drop = FALSE] |
|
889 |
+ PathR <- PathR[order(PathR[, 1], |
|
890 |
+ PathR[, 2]), , drop = FALSE] |
|
673 | 891 |
|
674 | 892 |
|
675 | 893 |
# Path1<-paste(Path1[,1],'-',Path1[,2],sep='',collapse=',') |
... | ... |
@@ -677,29 +895,34 @@ AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
677 | 895 |
NEv <- "NEv<-data.frame(EventID,GeneName,EventNumber,EventType,GPos,EventNumP," |
678 | 896 |
for (kk in seq_len(paths)) { |
679 | 897 |
if (kk <= EventNumP) { |
680 |
- command <- paste0("Path", kk, "<-paste(Path", kk, "[,1],'-',Path", |
|
681 |
- kk, "[,2],sep='',collapse=',')") |
|
898 |
+ command <- paste0("Path", |
|
899 |
+ kk, "<-paste(Path", kk, |
|
900 |
+ "[,1],'-',Path", kk, "[,2],sep='',collapse=',')") |
|
682 | 901 |
eval(parse(text = command)) |
683 | 902 |
# command <- |
684 |
- # paste0('ProbesP',kk,'<-paste(Events[[ii]]$Probes_P',kk,',collapse=',')') |
|
685 |
- # eval(parse(text = command)) |
|
903 |
+ # paste0('ProbesP',kk,'<-paste(Events[[ii]]$Probes_P', |
|
904 |
+ # kk,',collapse=',')') eval(parse(text = |
|
905 |
+ # command)) |
|
686 | 906 |
} else { |
687 |
- command <- paste0("Path", kk, "<-'-'") |
|
907 |
+ command <- paste0("Path", |
|
908 |
+ kk, "<-'-'") |
|
688 | 909 |
eval(parse(text = command)) |
689 |
- # command <- paste0('ProbesP',kk,'<-'-'') eval(parse(text = command)) |
|
910 |
+ # command <- paste0('ProbesP',kk,'<-'-'') |
|
911 |
+ # eval(parse(text = command)) |
|
690 | 912 |
} |
691 |
- NEv <- paste0(NEv, "Path", kk, ",") |
|
913 |
+ NEv <- paste0(NEv, "Path", kk, |
|
914 |
+ ",") |
|
692 | 915 |
} |
693 | 916 |
|
694 |
- PathR <- paste(PathR[, 1], "-", PathR[, 2], sep = "", collapse = ",") |
|
917 |
+ PathR <- paste(PathR[, 1], "-", PathR[, |
|
918 |
+ 2], sep = "", collapse = ",") |
|
695 | 919 |
NEv <- paste0(NEv, "PathR,stringsAsFactors = FALSE)") |
696 | 920 |
eval(parse(text = NEv)) |
697 | 921 |
rownames(NEv) <- NULL |
698 |
- # NEv<-data.frame(EventID,GeneName,EventNumber,EventType,GPos,Path1,Path2,PathR,stringsAsFactors |
|
699 |
- # = FALSE) |
|
922 |
+ # NEv<-data.frame(EventID,GeneName,EventNumber,EventType,GPos, |
|
923 |
+ # Path1,Path2,PathR,stringsAsFactors = |
|
924 |
+ # FALSE) |
|
700 | 925 |
Result[[ii]] <- NEv |
701 |
- |
|
702 |
- |
|
703 | 926 |
} |
704 | 927 |
|
705 | 928 |
Result <- do.call(rbind, Result) |
... | ... |
@@ -709,127 +932,168 @@ AnnotateEvents_RNASeq_MultiPath <- function(Events, paths) { |
709 | 932 |
if (kk == (paths + 1)) { |
710 | 933 |
command <- paste0(command, "'Path Ref')") |
711 | 934 |
} else { |
712 |
- command <- paste0(command, "'Path ", kk, "',") |
|
935 |
+ command <- paste0(command, "'Path ", |
|
936 |
+ kk, "',") |
|
713 | 937 |
} |
714 | 938 |
} |
715 | 939 |
eval(parse(text = command)) |
716 | 940 |
return(Result) |
717 |
- |
|
718 |
- |
|
719 | 941 |
} |
720 | 942 |
|
721 | 943 |
#' @rdname InternalFunctions |
722 |
-AnnotateEvents_KLL <- function(Events, Gxx, GenI) { |
|
944 |
+AnnotateEvents_KLL <- function(Events, Gxx, |
|
945 |
+ GenI) { |
|
723 | 946 |
{ |
724 | 947 |
# Gxx <- GeneName |
725 | 948 |
GeneName <- Gxx |
726 | 949 |
GeneID <- GenI |
727 |
- Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, "Chr"])) |
|
950 |
+ Chrom <- gsub("chr", "", as.vector(Events[[1]]$P1[1, |
|
951 |
+ "Chr"])) |
|
728 | 952 |
Result <- vector("list") |
729 | 953 |
# Flat<-vector('list') |
730 | 954 |
mm <- 0 |
731 | 955 |
|
732 | 956 |
for (ii in seq_along(Events)) { |
733 |
- if (!any(c(identical(unique(Events[[ii]]$P1$Type), "V"), identical(unique(Events[[ii]]$P2$Type), |
|
734 |
- "V"), identical(unique(Events[[ii]]$Ref$Type), "V")) == TRUE)) { |
|
957 |
+ if (!any(c(identical(unique(Events[[ii]]$P1$Type), |
|
958 |
+ "V"), identical(unique(Events[[ii]]$P2$Type), |
|
959 |
+ "V"), identical(unique(Events[[ii]]$Ref$Type), |
|
960 |
+ "V")) == TRUE)) { |
|
735 | 961 |
mm <- mm + 1 |
736 | 962 |
|
737 | 963 |
EventNumber <- ii |
738 | 964 |
|
739 | 965 |
EventType <- Events[[ii]]$Type |
740 | 966 |
|
741 |
- Positions <- rbind(Events[[ii]]$P1, Events[[ii]]$P2)[, 4:5] |
|
742 |
- Start <- as.numeric(Positions[, 1]) |
|
743 |
- End <- as.numeric(Positions[, 2]) |
|
744 |
- Start <- Start[which(Start != 0)] |
|
967 |
+ Positions <- rbind(Events[[ii]]$P1, |
|
968 |
+ Events[[ii]]$P2)[, 4:5] |
|
969 |
+ Start <- as.numeric(Positions[, |
|
970 |
+ 1]) |
|
971 |
+ End <- as.numeric(Positions[, |
|
972 |
+ 2]) |
|
973 |
+ Start <- Start[which(Start != |
|
974 |
+ 0)] |
|
745 | 975 |
End <- End[which(End != 0)] |
746 | 976 |
|
747 | 977 |
# browser() |
748 | 978 |
minGPos <- min(Start) |
749 | 979 |
maxGPos <- max(End) |
750 |
- GPos <- paste(Chrom, ":", minGPos, "-", maxGPos, sep = "") |
|
980 |
+ GPos <- paste(Chrom, ":", |
|
981 |
+ minGPos, "-", maxGPos, |
|
982 |
+ sep = "") |
|
751 | 983 |
|
752 |
- CP1s <- which(Events[[ii]]$P1[, 1] == "S") |
|
753 |
- CP1e <- which(Events[[ii]]$P1[, 2] == "E") |
|
984 |
+ CP1s <- which(Events[[ii]]$P1[, |
|
985 |
+ 1] == "S") |
|
986 |
+ CP1e <- which(Events[[ii]]$P1[, |
|
987 |
+ 2] == "E") |
|
754 | 988 |
|
755 |
- if (length(CP1s) > 0 | length(CP1e) > 0) { |
|
989 |
+ if (length(CP1s) > 0 | length(CP1e) > |
|
990 |
+ 0) { |
|
756 | 991 |
CC <- c(CP1s, CP1e) |
757 |
- Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, ] |
|
992 |
+ Events[[ii]]$P1 <- Events[[ii]]$P1[-CC, |
|
993 |
+ ] |
|
758 | 994 |
} |
759 | 995 |
|
760 |
- PS1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 1])) |
|
761 |
- PE1 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P1[, 2])) |
|
762 |
- Path1 <- as.matrix(cbind(PS1, PE1)) |
|
763 |
- Path1 <- Path1[order(Path1[, 1], Path1[, 2]), , drop = FALSE] |
|
996 |
+ PS1 <- as.numeric(gsub(".[ab]", |
|
997 |
+ "", Events[[ii]]$P1[, 1])) |
|
998 |
+ PE1 <- as.numeric(gsub(".[ab]", |
|
999 |
+ "", Events[[ii]]$P1[, 2])) |
|
1000 |
+ Path1 <- as.matrix(cbind(PS1, |
|
1001 |
+ PE1)) |
|
1002 |
+ Path1 <- Path1[order(Path1[, |
|
1003 |
+ 1], Path1[, 2]), , drop = FALSE] |
|
764 | 1004 |
|
765 |
- CP2s <- which(Events[[ii]]$P2[, 1] == "S") |
|
766 |
- CP2e <- which(Events[[ii]]$P2[, 2] == "E") |
|
1005 |
+ CP2s <- which(Events[[ii]]$P2[, |
|
1006 |
+ 1] == "S") |
|
1007 |
+ CP2e <- which(Events[[ii]]$P2[, |
|
1008 |
+ 2] == "E") |
|
767 | 1009 |
|
768 |
- if (length(CP2s) > 0 | length(CP2e) > 0) { |
|
1010 |
+ if (length(CP2s) > 0 | length(CP2e) > |
|
1011 |
+ 0) { |
|
769 | 1012 |
CC <- c(CP2s, CP2e) |
770 |
- Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, ] |
|
1013 |
+ Events[[ii]]$P2 <- Events[[ii]]$P2[-CC, |
|
1014 |
+ ] |
|
771 | 1015 |
} |
772 | 1016 |
|
773 |
- PS2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 1])) |
|
774 |
- PE2 <- as.numeric(gsub(".[ab]", "", Events[[ii]]$P2[, 2])) |
|
775 |
- Path2 <- as.matrix(cbind(PS2, PE2)) |
|
776 |
- Path2 <- Path2[order(Path2[, 1], Path2[, 2]), , drop = FALSE] |
|
1017 |
+ PS2 <- as.numeric(gsub(".[ab]", |
|
1018 |
+ "", Events[[ii]]$P2[, 1])) |
|
1019 |
+ PE2 <- as.numeric(gsub(".[ab]", |
|
1020 |
+ "", Events[[ii]]$P2[, 2])) |
|
1021 |
+ Path2 <- as.matrix(cbind(PS2, |
|
1022 |
+ PE2)) |
|
1023 |
+ Path2 <- Path2[order(Path2[, |
|
1024 |
+ 1], Path2[, 2]), , drop = FALSE] |
|
777 | 1025 |
|
778 |
- CPRs <- which(Events[[ii]]$Ref[, 1] == "S") |
|
779 |
- CPRe <- which(Events[[ii]]$Ref[, 2] == "E") |
|
1026 |
+ CPRs <- which(Events[[ii]]$Ref[, |
|
1027 |
+ 1] == "S") |
|
1028 |
+ CPRe <- which(Events[[ii]]$Ref[, |
|
1029 |
+ 2] == "E") |
|
780 |