Open tobiasko opened 1 year ago
Dear @tobiasko, as mentioned on the bioconductor support channel, the current implementation of the import function cannot handle replicates. Since from you email I understood that you can analyse each replicate separately without problems, there is a way to integrate TPP2D results obtained from two different replicates. It is a stringent approach that considers the lower F-statistic for each protein in each of the replicates under the constraint that the direction of the effect stabilisation/destabilisation is the same. Here is example code for integrating two replicates:
vem_r1_params_df <- getModelParamsDf(vem_r1_df, maxit = 500)
vem_r1_null_df <- bootstrapNullAlternativeModel(
df = vem_r1_df, params_df = vem_r1_params_df,
maxit = 500, B = 100,
BPPARAM = BiocParallel::MulticoreParam(workers = 10, progressbar = TRUE),
verbose = FALSE)
vem_r1_fstat_df <- computeFStatFromParams(vem_r1_params_df)
vem_r1_fdr_df <- getFDR(vem_r1_fstat_df,
vem_r1_null_df)
vem_r2_params_df <- getModelParamsDf(vem_r2_df, maxit = 500)
vem_r2_null_df <- bootstrapNullAlternativeModel(
df = vem_r2_df, params_df = vem_r2_params_df,
maxit = 500, B = 100,
BPPARAM = BiocParallel::MulticoreParam(workers = 10, progressbar = TRUE),
verbose = FALSE)
vem_r2_fstat_df <- computeFStatFromParams(vem_r2_params_df)
vem_r2_fdr_df <- getFDR(vem_r2_fstat_df,
vem_r2_null_df)
vem_fdr_combo_df <-
bind_rows(vem_r1_fdr_df,
vem_r2_fdr_df) %>%
group_by(clustername, dataset) %>%
filter(n() > 1, length(unique(sign(slopeH1))) == 1,
F_statistic == min(F_statistic)) %>%
ungroup %>%
group_by(nObsRound) %>%
arrange(desc(F_statistic)) %>%
mutate(max_rank = n(),
rank = dense_rank(dplyr::desc(F_statistic)),
is_decoy = ifelse(dataset != "true", 1, 0)) %>%
mutate(all_null = sum(is_decoy),
all_true = sum(!is_decoy),
true_cumsum = cumsum(!is_decoy),
null_cumsum = cumsum(is_decoy)) %>%
mutate(pi = (all_true-true_cumsum)/((all_null-null_cumsum)/B)) %>%
mutate(FDR = pi * (null_cumsum/B)/true_cumsum) %>%
ungroup() %>%
within(FDR[is.na(F_statistic)] <- NA)
vem_hits_combo_df <- findHits(vem_fdr_combo_df, 0.1)
Happy to hear if this works for you / the results make sense
Your code seems to expect an additional variable/column named B
in the bootstrapped data:
> ## combine FDR stat
> ## https://github.com/nkurzaw/TPP2D/issues/8
> fdr_combo_df <-
+ bind_rows(fdr_tab_df1_B20_mc, fdr_tab_df2_B20_mc) %>%
+ group_by(clustername, dataset) %>%
+ filter(n() > 1, length(unique(sign(slopeH1))) == 1, F_statistic == min(F_statistic)) %>%
+ ungroup %>%
+ group_by(nObsRound) %>%
+ arrange(desc(F_statistic)) %>%
+ mutate(max_rank = n(), rank = dense_rank(dplyr::desc(F_statistic)), is_decoy = ifelse(dataset != "true", 1, 0)) %>%
+ mutate(all_null = sum(is_decoy), all_true = sum(!is_decoy), true_cumsum = cumsum(!is_decoy), null_cumsum = cumsum(is_decoy)) %>%
+ mutate(pi = (all_true-true_cumsum)/((all_null-null_cumsum)/B)) %>%
+ mutate(FDR = pi * (null_cumsum/B)/true_cumsum) %>%
+ ungroup() %>%
+ within(FDR[is.na(F_statistic)] <- NA)
Error in `mutate()`:
ℹ In argument: `pi = (all_true - true_cumsum)/((all_null - null_cumsum)/B)`.
ℹ In group 1: `nObsRound = 20`.
Caused by error:
! object 'B' not found
Run `rlang::last_trace()` to see where the error occurred.
>
Is guess it is a counter for the bootstrap rounds performed by bootstrapNullAlternativeModel()
? My tables were bootstrapped using the default B = 20
and but lack this column.
Def. a variable B
in the global environment solves the code issue.
Dear @nkurzaw,
when I use the package function
import2Dataset()
in combination with replicated measurements (each temperature * drug combination was measured twice) it crashes. The function call isThe config table looks like this:
The data looks like:
Importing only rep1 or rep2 works without any problem! Am I doing something wrong?