alignToMaster: Align descendants to master

View source: R/merge_order.R

alignToMasterR Documentation

Align descendants to master

Description

During traverse-down, parent runs are aligned to the master/child run. This function performs the alignment by already saved aligned parent-child time vectors. For the aligned peaks, alignment_rank is set to 1 in multipeptide environment.

Usage

alignToMaster(
  ref,
  eXp,
  alignedVecs,
  refRun,
  adaptiveRT,
  multipeptide,
  prec2chromIndex,
  mzPntrs,
  fileInfo,
  precursors,
  params,
  applyFun = lapply
)

Arguments

ref

(string) name of the descendant run. Must be in the rownames of fileInfo.

eXp

(string) name of one of the parent run. Must be in the rownames of fileInfo.

alignedVecs

(list of dataframes) Each dataframe contains aligned parents time-vectors and resulting child/master time vector for a precursor. This is the second element of getChildXICs output.

refRun

(integer) must be of the same length as of precursors. 1: reference is runA, 2: reference is runB.

multipeptide

(environment) contains multiple data-frames that are collection of features associated with analytes. This is an output of getMultipeptide.

prec2chromIndex

(list) a list of dataframes having following columns:
transition_group_id: it is PRECURSOR.ID from osw file.
chromatogramIndex: index of chromatogram in mzML file.

mzPntrs

(list) a list of mzRpwiz.

fileInfo

(data-frame) output of getRunNames.

precursors

(data-frame) atleast two columns transition_group_id and transition_ids are required.

params

(list) parameters are entered as list. Output of the paramsDIAlignR function.

applyFun

(function) value must be either lapply or BiocParallel::bplapply.

Details

refRun is flipped if eXp is runB instead of runA.

Value

(None)

Author(s)

Shubham Gupta, shubh.gupta@mail.utoronto.ca

ORCID: 0000-0003-3500-8152

License: (c) Author (2020) + GPL-3 Date: 2020-07-19

See Also

traverseUp, traverseDown, setAlignmentRank

Examples

dataPath <- system.file("extdata", package = "DIAlignR")
params <- paramsDIAlignR()
fileInfo <- DIAlignR::getRunNames(dataPath = dataPath)
mzPntrs <- list2env(getMZMLpointers(fileInfo))
features <- list2env(getFeatures(fileInfo, maxFdrQuery = 0.05, runType = "DIA_Proteomics"))
precursors <- getPrecursors(fileInfo, oswMerged = TRUE, runType = params[["runType"]],
 context = "experiment-wide", maxPeptideFdr = params[["maxPeptideFdr"]])
precursors <- dplyr::arrange(precursors, .data$peptide_id, .data$transition_group_id)
peptideIDs <- unique(precursors$peptide_id)
peptideScores <- getPeptideScores(fileInfo, peptideIDs, oswMerged = TRUE, params[["runType"]], params[["context"]])
peptideScores <- lapply(peptideIDs, function(pep) dplyr::filter(peptideScores, .data$peptide_id == pep))
names(peptideScores) <- as.character(peptideIDs)
prec2chromIndex <- list2env(getChromatogramIndices(fileInfo, precursors, mzPntrs))
multipeptide <- getMultipeptide(precursors, features)
prec2chromIndex <- list2env(getChromatogramIndices(fileInfo, precursors, mzPntrs))
adaptiveRTs <- new.env()
refRuns <- new.env()
tree <- ape::reorder.phylo(ape::read.tree(text = "(run1:7,run2:2)master1;"), "postorder")
## Not run: 
ropenms <- get_ropenms(condaEnv = "envName", useConda=TRUE)
multipeptide <- traverseUp(tree, dataPath, fileInfo, features, mzPntrs, prec2chromIndex, precursors, params,
 adaptiveRTs, refRuns, multipeptide, peptideScores, ropenms)
multipeptide <- getMultipeptide(precursors, features)
alignedVecs <- readRDS(file = file.path(dataPath, "master1_av.rds"))
adaptiveRT <- (adaptiveRTs[["run1_run2"]] + adaptiveRTs[["run2_run1"]])/2
multipeptide[["14383"]]$alignment_rank[multipeptide[["14383"]]$run == "master1"] <- 1L
multipeptide <- alignToMaster(ref = "master1", eXp = "run1", alignedVecs, refRuns[["master1"]][,1], adaptiveRT,
 multipeptide, prec2chromIndex, mzPntrs, fileInfo, precursors, params)
# Cleanup
for(run in names(mzPntrs)) DBI::dbDisconnect(mzPntrs[[run]])
file.remove(file.path(dataPath, "master1_av.rds"))
file.remove(file.path(dataPath, "xics", "master1.chrom.sqMass"))

## End(Not run)

shubham1637/DIAlign documentation built on March 27, 2023, 7:12 a.m.