conservation: conservation

Description Usage Details Value Author(s) References See Also Examples

Description

Draw a conservative curve, calculate the conservative score

Usage

1

Details

The tool ennable visualization of amino acid changes at the protein level,The scale of a protein domain and the position of a functional motif/site will be precisely defined. The features available includeting conservation, conservation score

Value

The returned value is a conservative score

Author(s)

Xiaoyu Zhang

References

https://cran.r-project.org/doc/manuals/R-exts.html

See Also

help

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
##---- 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 () 
{
    protein = read.table("Protein.txt", sep = "\t", stringsAsFactors = F)
    domain = read.table("Domain.txt", sep = "\t", stringsAsFactors = F)
    length = read.table("Length.txt", sep = "\t", stringsAsFactors = F)
    site = read.table("Site.txt", sep = "\t", stringsAsFactors = F)
    muta = read.table("Mutagenesis.txt", sep = "\t", stringsAsFactors = F)
    option = read.table("Option.txt", sep = "\t", stringsAsFactors = F)
    zoomin = read.table("ZoomIn.txt", sep = "\t", stringsAsFactors = F)
    nameOfYourQuery = option[2, 1]
    additionalOptions = option[2, 2]
    showReferenceSequence = option[2, 3]
    showConservationScore = option[2, 4]
    showGridlinesAtTicks = option[2, 5]
    conservation = option[2, 6]
    zoomIn = zoomin[2, 1]
    zoomStart = zoomin[2, 2]
    zoomEnd = zoomin[2, 3]
    tickSize = as.numeric(zoomin[2, 4])
    referenceSequencePositionInFile = option[2, 7]
    option = read.table("Option.txt", sep = "\t", stringsAsFactors = F)
    a <- read.fasta(file = "alignmentFile.fasta")
    seq <- list()
    for (i in 1:length(a)) {
        seq[[i]] <- a[[i]][1:length(a[[i]])]
    }
    numberOfSeq <- length(seq)
    mat <- matrix(0, nrow = length(a), ncol = length(a[[1]]))
    for (i in 1:length(seq)) {
        mat[i, ] <- seq[[i]]
    }
    df <- as.data.frame(mat)
    tdf <- t(df)
    referenceSequencePositionInFile = option[2, 7]
    referenceSeq <- tdf[which(tdf[, as.numeric(referenceSequencePositionInFile)] != 
        "-"), ]
    referenceSeq <- as.data.frame(referenceSeq)
    write.table(referenceSeq, file = "alignment_table", sep = "\t", 
        quote = F, row.names = F, col.names = F)
    counter <- rep(0, nrow(referenceSeq))
    a <- read.table("alignment_table", sep = "\t")
    a <- data.frame(lapply(a, as.character), stringsAsFactors = FALSE)
    for (i in 1:nrow(a)) {
        a[i, "consensus"] <- paste(as.character(a[i, ]), collapse = "")
    }
    countBases <- function(string) {
        table(strsplit(string, "")[[1]])
    }
    c <- as.character(a[, "consensus"])
    tab <- list()
    for (i in 1:length(c)) {
        tab[[i]] <- countBases(c[i])
    }
    score <- rep(0, nrow(a))
    for (i in 1:length(tab)) {
        for (j in 1:length(tab[[i]])) {
            if ((names(tab[[i]][j])) == a[i, ][as.numeric(referenceSequencePositionInFile)]) 
                score[i] <- tab[[i]][j]
        }
    }
    scorePlot <- -(((score/numberOfSeq)))
    a <- read.fasta(file = "alignmentFile.fasta")
    seqForPlot <- a[[as.numeric(referenceSequencePositionInFile)]][
which(a[[as.numeric(referenceSequencePositionInFile)]] != 
        "-")]
    if (additionalOptions == "yes") {
        if (conservation == "yes") {
            lines(scorePlot, col = "purple3")
        }
    }
    if (additionalOptions == "yes") {
        if (showReferenceSequence == "yes") {
            rect(0, -4.75, length(scorePlot), -5.05, col = "white", 
                border = NA)
            for (i in 1:length(seqForPlot)) {
                text(i, -4.9, toupper(seqForPlot[i]), font = 2, 
                  cex = 1)
            }
        }
    }
    if (additionalOptions == "yes") {
        if (showConservationScore == "yes") {
            rect(0, 0.3, length(scorePlot), 0.7, col = "white", 
                border = NA)
            for (i in 1:length(seqForPlot)) {
                text(i, 0.5, toupper(abs(round(scorePlot[i], 
                  1))), font = 2, cex = 0.8, srt = 90, col = "purple3")
            }
        }
    }
  }

plotprotein documentation built on May 1, 2019, 8:44 p.m.