insightsengineering / tern

Table, Listings, and Graphs (TLG) library for common outputs used in clinical trials
https://insightsengineering.github.io/tern/
Other
73 stars 17 forks source link

[Bug]: Imputation rule 50 % does not work #1208

Open legrasv opened 3 months ago

legrasv commented 3 months ago

What happened?

the function analyze_vars_in_cols.R would have to be refined.

It's quite a complex issue that we didn't think about when you develop the function I guess. image

In this example, I was using: imp_rule = "1/2", avalcat_var = "AVALC", na_str = "NE"

The thing is that the n NON BLQ >= 1/2 is not calculated correctly, in the example above, at 288H, there are 4 patients, only two have a pk sample, and 1 is BLQ, one is non BLQ. The formula to report the statistics should be nNONBLQ >= 1/2, but taking in account all the patients of the treatment arm so: 1 / 4 >= 1/2, FALSE, so it the summary statistics should not appear for the timepoint 288H. (While now the calculation used is 1 / 2 >=1/2)

Another thing which would be more tricky to implement is: image In this one, it looks correct, but the thing is we actually don't have 3 patients in the treatment arm, but 6 patients! But 3 of them where considered as excluded (filter(ANL01FL == "Y")). So the 1/2 rule should be applied on the n = 6, meaning at timepoint 4H, we have 3/6 nonBLQ values, fine, we have the statistics. But for the timepoint at 360H, we have actually 2/6 (<= 1/2) non BLQ so the summary statistics should not appear.

This issue comes from the fact the we didn't take in account when developing the functions that there could be excluded patients ANL01FL == "Y" (so this should be kept over the workflow to keep the 6 patients as a n() of reference for the calculation nNonBLQ / n >= 1/2). This is actually the first line of code I have in my script:

t_pkconc <- function(datasets){
    adpc <- datasets$adpc %>% filter(ANL01FL == "Y")

Would there be the possibility to fix that bugs? please

sessionInfo()

No response

Relevant log output

No response

Code of Conduct

Contribution Guidelines

Security Policy

legrasv commented 3 months ago

The easiest solution and most flexible one would in my view would be: (similar the param in g_lineplot #' @param alt_counts_df (data.frame or NULL)\cr data set that will be used (only) to counts objects in strata.)

legrasv commented 3 months ago

@Melkiades I contacted gRED it looks like we may not have the same guidelines, I will update your asap. Put this on hold for now.

legrasv commented 2 months ago

@Melkiades @ayogasekaram Please put this issue in the archive, it's not needed yet as this issue would tackle only a few studies with very specific data (1 %) and we may not we to be that precise for this summary table. We don't need to do the development of this one unless I come back later with more information that makes us think that we should do it.

Thank you!