Skip to content

Commit

Permalink
fix correlation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywu1999 committed Jan 22, 2025
1 parent 6d5653d commit 00610de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions R/getSubnetworkFromIndra.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#' corresponding p-values, logFCs, along with additional HGNC ID and HGNC
#' name columns
#' @param protein_level_data output of the \code{\link[MSstats]{dataProcess}}
#' function, which contains a list of proteins and their corresponding abundances.
#' Used for annotating correlation information and applying correlation cutoffs.
#' function's ProteinLevelData table, which contains a list of proteins and
#' their corresponding abundances. Used for annotating correlation information
#' and applying correlation cutoffs.
#' @param pvalueCutoff p-value cutoff for filtering. Default is NULL, i.e. no
#' filtering
#' @param statement_types list of interaction types to filter on. Equivalent to
Expand Down
8 changes: 4 additions & 4 deletions R/utils_getSubnetworkFromIndra.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@
)
# add correlation - maybe create a separate function
if (!is.null(protein_level_data)) {
protein_level_data <- Filter(function(row)
(row$Protein %in% edges$source | row$Protein %in% edges$target),
protein_level_data)
protein_level_data <- protein_level_data[
protein_level_data$Protein %in% edges$source |
protein_level_data$Protein %in% edges$target, ]
wide_data = pivot_wider(protein_level_data[,c("Protein", "LogIntensities", "originalRUN")], names_from = Protein, values_from = LogIntensities)
wide_data <- wide_data[, -which(names(wide_data) == "originalRUN")]
correlations = cor(wide_data, use = "pairwise.complete.obs")
edges$correlation = lapply(function(edge) correlations[edge$source, edge$target], edges)
edges$correlation = apply(edges, 1, function(edge) correlations[edge["source"], edge["target"]])
}
return(edges)
}
Expand Down
5 changes: 3 additions & 2 deletions man/getSubnetworkFromIndra.Rd

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

0 comments on commit 00610de

Please sign in to comment.