Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditionally and persisitently rare taxa #98

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Conversation

Daenarys8
Copy link
Contributor

ping #83

Signed-off-by: Daena Rys <[email protected]>
R/addMetrics.R Show resolved Hide resolved
R/addMetrics.R Show resolved Hide resolved
R/addMetrics.R Show resolved Hide resolved
Comment on lines +54 to +77
# Calculate metrics for each split subject/group
results_list <- lapply(split_data, function(sub_data) {
# Initialize a list to hold results for each metric
metric_results <- list()

# Loop through each metric and calculate it
for (metric in metrics) {
# Check if the metric is supported and calculate accordingly
if (metric == "CRT") {
crt_results <- .calculateCRT(sub_data, thresholds[["CRT"]])
metric_results[["CRT"]] <- crt_results
} else {
stop(paste("Metric", metric, "is not supported yet."),
call. = FALSE)
}
}

# Add the calculated metrics to the metadata (colData or rowData)
for (metric in names(metric_results)) {
colData(sub_data)[[metric]] <- metric_results[[metric]]
}

return(sub_data)
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more efficient to:

  1. Get matrix
  2. Get the list which has vectors as elements. Each vector represent members of each group
  3. Loop through this list
  4. Select the group members from the matrix
  5. Calculate values
  6. Combine all the results and sort values based on sample names
  7. Add to colData (in add* method)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants