1 | trainDataConstractor(peptide.unique.fractions.pId, peptide.unique.fractions, numfraction, protein.weight, protein.length, protein.tryptic, protein.pI)
|
peptide.unique.fractions.pId |
|
peptide.unique.fractions |
|
numfraction |
|
protein.weight |
|
protein.length |
|
protein.tryptic |
|
protein.pI |
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (peptide.unique.fractions.pId, peptide.unique.fractions,
numfraction, protein.weight, protein.length, protein.tryptic,
protein.pI)
{
fraction.weight <- list()
fraction.length <- list()
fraction.tryptic <- list()
fraction.pI <- list()
length(fraction.weight) <- numfraction
length(fraction.length) <- numfraction
length(fraction.tryptic) <- numfraction
length(fraction.pI) <- numfraction
stp <- 100
recorder <- 0
for (i in 1:length(peptide.unique.fractions.pId)) {
recorder <- recorder + 1
pId <- peptide.unique.fractions.pId[i]
sId <- NULL
opt.sId <- as.numeric(which.max(peptide.unique.fractions[i,
]))
r <- sum(!is.na(peptide.unique.fractions[i, ]))
if (r < 3) {
sId <- opt.sId
}
else if (max(peptide.unique.fractions[i, ], na.rm = T) !=
median(as.numeric(peptide.unique.fractions[i, ]),
na.rm = T)) {
sId <- opt.sId
}
else {
sId <- opt.sId + 1
}
tmp <- fraction.weight[[sId]]
tmp <- c(tmp, protein.weight[pId])
fraction.weight[[sId]] <- tmp
tmp <- fraction.length[[sId]]
tmp <- c(tmp, protein.length[pId])
fraction.length[[sId]] <- tmp
tmp <- fraction.tryptic[[sId]]
tmp <- c(tmp, protein.tryptic[pId])
fraction.tryptic[[sId]] <- tmp
tmp <- fraction.pI[[sId]]
tmp <- c(tmp, protein.pI[pId])
fraction.pI[[sId]] <- tmp
if (recorder == stp) {
print(i)
recorder <- 0
}
}
fraction <- list()
for (i in 1:numfraction) {
fraction[[i]] <- summary(as.factor(names(fraction.weight[[i]])),
maxsum = Inf)
}
pId <- unique(peptide.unique.fractions.pId)
for (i in 1:length(pId)) {
assignment <- c()
for (j in 1:numfraction) {
assignment <- c(assignment, fraction[[j]][pId[i]])
}
count <- sum(!is.na(assignment))
if (count > 1) {
best.sId <- which.max(assignment)
del.idx <- which(!is.na(assignment))
for (j in 1:length(del.idx)) {
idx <- del.idx[j]
if (idx != best.sId) {
del <- which(names(fraction.weight[[idx]]) ==
pId[i])
fraction.weight[[idx]] <- fraction.weight[[idx]][-c(del)]
fraction.length[[idx]] <- fraction.length[[idx]][-c(del)]
fraction.tryptic[[idx]] <- fraction.tryptic[[idx]][-c(del)]
fraction.pI[[idx]] <- fraction.pI[[idx]][-c(del)]
}
}
}
}
train.raw <- list()
train.raw$fraction.weight <- fraction.weight
train.raw$fraction.length <- fraction.length
train.raw$fraction.tryptic <- fraction.tryptic
train.raw$fraction.pI <- fraction.pI
return(train.raw)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.