AnnekathrinSilvia / magnetique

Source code for the magnetique application
MIT License
2 stars 3 forks source link

DTU dif showing as NaN #50

Closed tbrittoborges closed 2 years ago

tbrittoborges commented 2 years ago

Potential problem in the https://github.com/AnnekathrinSilvia/magnetique/blame/main/gen_sqlite.R

eboileau commented 2 years ago

Ordering must be done per gene, this after grouping. I am not sure why, but arrange does not work, I used slice_min and it works.

Also, if you summarize afterwards, I think you loose the actual (initial) number of transcripts per gene, and if you don't filter the transcripts before summarizing (dtu_diff), then the calculation is not correct. Replacing lines 138-147 by

res_dtu <- rowdata[[.x]] %>% group_by(gene_id) %>% add_tally() %>%
                    slice_min(order_by = adj_pvalue) %>%
                    filter(row_number() == 1) %>% 
                    dplyr::rename(dtu_pvadj=adj_pvalue) %>%
                    mutate(dtu_dif=compute_usage_dif(feature_id, dtu, contrast)) %>%
                    select(gene_id, n, dtu_pvadj, dtu_dif)

should work. I have tried it locally.

@tbrittoborges Could you make the change in your working branch, and take care of eventually merging? I'll leave the issue open until we have seen it working in the app.

tbrittoborges commented 2 years ago

Leaving this one open for review.