determineProteinID: working on...

Usage Arguments Examples

Usage

1
determineProteinID(peptide, peptide.slice.assignment, peptide.original.assignment, fdr.cutoff = 0.01, fdr.stp = 20)

Arguments

peptide
peptide.slice.assignment
peptide.original.assignment
fdr.cutoff
fdr.stp

Examples

  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
##---- 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, peptide.slice.assignment, peptide.original.assignment, 
    fdr.cutoff = 0.01, fdr.stp = 20) 
{
    peptide.slice.unique.idx <- lapply(strsplit(peptide.slice.assignment, 
        ";"), length) == 1
    peptide.original.unique.idx <- lapply(strsplit(peptide.original.assignment, 
        ";"), length) == 1
    peptide.slice.unique <- peptide.slice.assignment[peptide.slice.unique.idx]
    peptide.original.unique <- peptide.original.assignment[peptide.original.unique.idx]
    protein.slice.unique <- unique(peptide.slice.unique)
    protein.original.unique <- unique(peptide.original.unique)
    protein.slice.peptideCount <- summary(as.factor(peptide.slice.unique), 
        maxsum = Inf)
    protein.original.peptideCount <- summary(as.factor(peptide.original.unique), 
        maxsum = Inf)
    protein.slice.multiPeptide <- names(protein.slice.peptideCount)[(protein.slice.peptideCount > 
        1)]
    protein.original.multiPeptide <- names(protein.original.peptideCount)[(protein.original.peptideCount > 
        1)]
    peptide.slice.pep <- cbind(peptide[peptide.slice.unique.idx, 
        "PEP"], peptide.slice.unique)
    rownames(peptide.slice.pep) <- names(peptide.slice.unique)
    colnames(peptide.slice.pep) <- c("PEP", "pId")
    peptide.original.pep <- cbind(peptide[peptide.original.unique.idx, 
        "PEP"], peptide.original.unique)
    rownames(peptide.original.pep) <- names(peptide.original.unique)
    colnames(peptide.original.pep) <- c("PEP", "pId")
    peptide.slice.pep.sort <- peptide.slice.pep[order(peptide.slice.pep[, 
        "PEP"]), ]
    peptide.original.pep.sort <- peptide.original.pep[order(peptide.original.pep[, 
        "PEP"]), ]
    protein.slice.PEP <- c()
    for (i in 1:length(protein.slice.multiPeptide)) {
        prot <- peptide.slice.pep.sort[which(peptide.slice.pep.sort[, 
            "pId"] == protein.slice.multiPeptide[i]), "PEP"]
        protein.slice.PEP <- c(protein.slice.PEP, prod(as.numeric(prot)))
    }
    names(protein.slice.PEP) <- protein.slice.multiPeptide
    protein.slice.sort <- protein.slice.PEP[order(protein.slice.PEP)]
    protein.original.PEP <- c()
    for (i in 1:length(protein.original.multiPeptide)) {
        prot <- peptide.original.pep.sort[which(peptide.original.pep.sort[, 
            "pId"] == protein.original.multiPeptide[i]), "PEP"]
        protein.original.PEP <- c(protein.original.PEP, prod(as.numeric(prot)))
    }
    names(protein.original.PEP) <- protein.original.multiPeptide
    protein.original.sort <- protein.original.PEP[order(protein.original.PEP)]
    index <- 0
    count <- 0
    stp <- fdr.stp
    decoy <- 0
    for (i in 1:length(protein.slice.sort)) {
        count <- count + 1
        if (regexpr("REV__", names(protein.slice.sort)[i]) > 
            0) {
            decoy <- decoy + 1
        }
        if (stp == count) {
            count <- 0
            fdr <- 2 * decoy/i
            index <- i
            if (fdr > fdr.cutoff) {
                break()
            }
        }
    }
    protein.slice.filtered <- protein.slice.sort[1:index]
    index <- 0
    count <- 0
    stp <- fdr.stp
    decoy <- 0
    for (i in 1:length(protein.original.sort)) {
        count <- count + 1
        if (regexpr("REV__", names(protein.original.sort)[i]) > 
            0) {
            decoy <- decoy + 1
        }
        if (stp == count) {
            count <- 0
            fdr <- 2 * decoy/i
            index <- i
            if (fdr > fdr.cutoff) {
                break()
            }
        }
    }
    protein.original.filtered <- protein.original.sort[1:index]
    protein.slice.filtered <- protein.slice.filtered[grep("REV", 
        invert = T, names(protein.slice.filtered))]
    protein.slice.filtered <- protein.slice.filtered[grep("CON", 
        invert = T, names(protein.slice.filtered))]
    protein.original.filtered <- protein.original.filtered[grep("REV", 
        invert = T, names(protein.original.filtered))]
    protein.original.filtered <- protein.original.filtered[grep("CON", 
        invert = T, names(protein.original.filtered))]
    result <- list()
    result$fraction <- protein.slice.filtered
    result$original <- protein.original.filtered
    result$fraction.pepSort <- peptide.slice.pep.sort
    result$original.pepSort <- peptide.original.pep.sort
    return(result)
  }

PengyiYang/ReFraction documentation built on May 14, 2019, 11:01 p.m.