-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
133 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: PhyloProfile | ||
Version: 1.19.2 | ||
Date: 2024-06-07 | ||
Date: 2024-06-11 | ||
Title: PhyloProfile | ||
Authors@R: c( | ||
person("Vinh", "Tran", role = c("aut", "cre"), email = "[email protected]", comment=c(ORCID="0000-0001-6772-7595")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -837,6 +837,76 @@ resolveOverlapFeatures <- function(domainDf) { | |
return(domainDf) | ||
} | ||
|
||
#' Linearize PFAM/SMART annotations by best e-value/bitscore | ||
#' @export | ||
#' @param domainDf input domain dataframe | ||
#' @param orthoID ID of protein that needs to be linearized | ||
#' @param value type of values that will be used for linearized, either evalue | ||
#' (default) or bitscore | ||
#' @return Domain dataframe of the selected protein after linearization | ||
#' @author Vinh Tran [email protected] | ||
#' @importFrom dplyr arrange | ||
#' @examples | ||
#' demoDomainDf <- data.frame( | ||
#' orthoID = rep("protID", 4), | ||
#' start = c(1, 5, 100, 80), | ||
#' end = c(30, 40, 130, 110), | ||
#' evalue = c(0.001, 0.0005, 0.2, 0.004), | ||
#' feature_type = c(rep("pfam", 2), rep("smart", 2)), | ||
#' feature_id = c("pf1", "pf2", "sm1", "sm2") | ||
#' ) | ||
#' linearizeArchitecture(demoDomainDf, "protID", "evalue") | ||
|
||
linearizeArchitecture <- function( | ||
domainDf = NULL, orthoID = NULL, value = "evalue" | ||
) { | ||
if (is.null(domainDf) | is.null(orthoID)) stop("Input data is NULL!") | ||
evalue <- bitscore <- start <- end <- NULL | ||
# Sort the dataframe by start position and then by evalue or bitscore | ||
if (value == "evalue") { | ||
domainDf <- domainDf %>% dplyr::arrange(start, evalue) | ||
} else if (value == "bitscore") { | ||
domainDf <- domainDf %>% dplyr::arrange(start, bitscore) | ||
} else stop("Incorrect value specified! Either 'evalue' or 'bitscore'") | ||
|
||
# Get lines that need to be excluded | ||
pfamRows <- rownames(domainDf[domainDf$orthoID == orthoID & | ||
domainDf$feature_type %in% c("pfam","smart"),]) | ||
exclude_lines <- vapply( | ||
seq_len(length(pfamRows)-1), | ||
function(i) { | ||
if (domainDf[pfamRows[i],]$end >= domainDf[pfamRows[i+1],]$start) { | ||
# Exclude the row with the higher evalue / lower bitscore | ||
if (value == "evalue") { | ||
if ( | ||
domainDf[pfamRows[i],]$evalue > | ||
domainDf[pfamRows[i+1],]$evalue | ||
) { | ||
return((pfamRows[i])) | ||
} else { | ||
return((pfamRows[i+1])) | ||
} | ||
} else { | ||
if ( | ||
domainDf[pfamRows[i],]$bitscore < | ||
domainDf[pfamRows[i+1],]$bitscore | ||
) { | ||
return((pfamRows[i])) | ||
} else { | ||
return((pfamRows[i+1])) | ||
} | ||
} | ||
|
||
} else { | ||
return("0") | ||
} | ||
}, | ||
character(1) | ||
) | ||
# return domainDf after removing overlapped features with higher e-values | ||
outDf <- domainDf[!(row.names(domainDf) %in% exclude_lines), ] | ||
return(outDf[outDf$orthoID == orthoID,]) | ||
} | ||
|
||
#' Add colors for each feature/domain | ||
#' @description Add colors to features/domains of 2 domain dataframes. Users can | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.