Here is the error and traceback from the PDtoMSstatsWeightedSummary using the input formatted by my function.
Error:
Error in `[[<-.data.frame`(`*tmp*`, "intercept", value = 1) :
replacement has 1 row, data has 0
Traceback:
13: stop(sprintf(ngettext(N, "replacement has %d row, data has %d",
"replacement has %d rows, data has %d"), N, nrows), domain = NA)
12: `[[<-.data.frame`(`*tmp*`, "intercept", value = 1)
11: `[[<-`(`*tmp*`, "intercept", value = 1)
10: getProteinSummaryDesign(feature_data)
9: summarizeProteinsClusterSingleRun(input_loop, initial_weights,
norm, norm_parameter, use_shared = FALSE)
8: getInitialSummary(input_loop, norm, norm_parameter, initial_summary)
7: getWeightedSummarySingleRun(x, peptide_protein_dt, norm, norm_parameter,
weights_mode, tolerance, max_iter, initial_summary, weights_penalty,
weights_penalty_param)
6: FUN(X[[i]], ...)
5: lapply(input_by_run, function(x) {
getWeightedSummarySingleRun(x, peptide_protein_dt, norm,
norm_parameter, weights_mode, tolerance, max_iter, initial_summary,
weights_penalty, weights_penalty_param)
})
4: FUN(X[[i]], ...)
3: lapply(cluster_input, function(single_cluster) {
input_by_run = split(single_cluster, single_cluster[, Run])
peptide_protein_dt = unique(single_cluster[, .(ProteinName,
PSM, Run)])
output_by_run = lapply(input_by_run, function(x) {
getWeightedSummarySingleRun(x, peptide_protein_dt, norm,
norm_parameter, weights_mode, tolerance, max_iter,
initial_summary, weights_penalty, weights_penalty_param)
})
summarized_output = data.table::rbindlist(lapply(output_by_run,
function(x) x[["summary"]]))
alphas_list = lapply(output_by_run, function(x) x[["alpha_history"]])
alpha_diffs = lapply(output_by_run, function(x) x[["convergence_history"]])
list(summary = summarized_output, pp_dt = peptide_protein_dt,
alpha_history = alphas_list, convergence_history = alpha_diffs)
})
2: getClusterSummaries(cluster_input, norm, norm_parameter, weights_mode,
tolerance, max_iter, initial_summary, weights_penalty, weights_penalty_param)
1: getWeightedProteinSummary(MSstatsTMT_input, norm = "p_norm",
norm_parameter = 1, weights_mode = "contributions", tolerance = 0.1,
max_iter = 10, initial_summary = "unique", weights_penalty = FALSE,
weights_penalty_param = 0.1, save_weights_history = FALSE,
save_convergence_history = FALSE)