Skip to content

Commit

Permalink
update pullProteinPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Carol-seven committed Oct 30, 2024
1 parent 6b303f7 commit ad55eeb
Show file tree
Hide file tree
Showing 13 changed files with 902 additions and 109 deletions.
40 changes: 35 additions & 5 deletions R/pullProteinPath.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,52 @@
#' @description
#' Summarize the steps performed on the data for one protein.
#'
#' @param proteinName A string identifying the protein of interest.
#' @param listName A character vector identifying the proteins of interest.
#'
#' @param regexName A character vector specifying the proteins for regular expression
#' pattern matching.
#'
#' @param dataSetList A list of data frames, the order dictates the order of presentation.
#'
#' @details \code{proteinName} must match the labels in the data sets exactly.
#' @param proteinInformation The name of the .csv file containing protein information data
#' (including the path to the file, if needed). This file is automatically generated by
#' the function \code{\link[msDiaLogue]{preprocessing}}.
#'
#' @returns A 2d dataframe, with the protein data at each step present in the \code{dataSetList}.
#'
#' @autoglobal
#'
#' @export

pullProteinPath <- function(proteinName, dataSetList) {
pullProteinPath <- function(listName = NULL, regexName = NULL, dataSetList,
proteinInformation = "preprocess_protein_information.csv") {

allnames <- colnames(dataSetList[[1]])[!colnames(dataSetList[[1]]) %in% c("R.Condition", "R.Replicate")]

## only list filter if listName is present
if (!is.null(listName)) {
listName <- allnames[which(allnames %in% listName)]
}

## only regex filter if regexName is present
if (!is.null(regexName)) {
regexName <- grep(paste(regexName, collapse = "|"), allnames, value = TRUE)
}

## combine protein names from list and regex filters
unionName <- union(listName, regexName)

proteinPath <- do.call(rbind, lapply(unionName, function(name) {
cbind(dataSetList[[1]][c("R.Condition", "R.Replicate")],
Protein = name,
sapply(dataSetList, function(data) data[[name]]))
}))

proteinPath <- cbind(dataSetList[[1]][c("R.Condition", "R.Replicate")],
sapply(dataSetList, function(mat) mat[[proteinName]]))
if (!is.null(proteinInformation)) {
proteinInformation <- read.csv(proteinInformation)
proteinPath <- merge(proteinPath, proteinInformation,
by.x = "Protein", by.y = "PG.ProteinNames", sort = FALSE)
}

## return the path of data for this protein
return(proteinPath)
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/cust_vis.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/scaffold.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad55eeb

Please sign in to comment.