Allow to customize merge keys
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- r
- Ambito
- data-engineering
Direzione di ricerca
Inizia esaminando il design collegato di data_extract/data_merge e le chiavi predefinite correnti di teal, quindi confronta gli esempi ADLB che usano drop_keys e chiavi di join personalizzate. Chiarisci se il risultato debba essere costituito da chiavi di Merge configurabili con visualizzazione delle chiavi di join, da una modifica delle chiavi di teal o da una documentazione ampliata; il lavoro sarà completato quando saranno concordati l’ambito e il comportamento per gli scenari di Merge elencati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem description
Design of data_extract/data_merge is as follows. Consider columns taken from datasets, filtered separately and merged all together.

Above can be express in the following code
library(scda)
library(dplyr)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADTTE <- synthetic_cdisc_data("latest")$adtte
ANL1 <- ADTTE %>% filter(PARAMCD == "CRSD") %>% select(STUDYID, USUBJID, AVAL)
ANL2 <- ADSL %>% select(STUDYID, USUBJID, AGE)
ANL <- left_join(ANL1, ANL2, by = c("STUDYID", "USUBJID"))
# STUDYID USUBJID AVAL AGE
# <chr> <chr> <dbl> <int>
# 1 AB12345 AB12345-BRA-1-id-105 1274. 38
# 2 AB12345 AB12345-BRA-1-id-134 545. 47
# 3 AB12345 AB12345-BRA-1-id-141 77.2 35
# 4 AB12345 AB12345-BRA-1-id-236 336. 32
# 5 AB12345 AB12345-BRA-1-id-265 270. 25
Merge module supports multiple scenarios and keys management is the "key" here. Consider following scenario where we have a two selectors to compare specific AVAL level from the same dataset across different factor values - for example AVAL increase between two visits
ADLB <- synthetic_cdisc_data("latest")$adlb
keys <- c("STUDYID", "USUBJID", "PARAMCD", "AVISITN")
ANL1 <- ADLB %>%
filter(PARAMCD == "CRP" & AVISITN == "-1") %>%
select(keys, -PARAMCD, -AVISITN, AVAL1 = AVAL)
ANL2 <- ADLB %>%
filter(PARAMCD == "CRP" & AVISITN == "0") %>%
select(keys, -PARAMCD, -AVISITN, AVAL2 = AVAL)
ANL <- left_join(ANL1, AN2, by = c("STUDYID", "PARAMCD"))
In above example, PARAMCD and AVISITN in both selectors have just one value which means that it's no longer the key for these ANLs as they were filtered-out (does not distinguish the rows). The reason to drop these keys is that it wouldn't be possible if by = c("USUBJID", "STUDYID", "PARAMCD", "AVISITN") because they have a different values and it's not possible to merge them together.
For scda data we have no problem with this as we have a static data and keys are relevant for our test data. Problems starts when SMEs create their own apps which are using real data. The keys used to be different than default teal keys, but the keys follow GDSR requirements. For example ADLB keys are STUDYID USUBJID PARAMCD BASETYPE AVISITN ATPTN DTYPE ADTM LBSEQ ASPID vs teal STUDYID USUBJID PARAMCD AVISIT. SMEs require the change in the keys to fit GDSR standards which complicates the design little bit.
If we go back to the last example which is using ADLB. Extending set of keys will result in joining by keys which have not been filtered-out. This means that ANLs will be joined by "STUDYID", "USUBJID", "ATPTN", "DTYPE", "ADTM", "LBSEQ", "ASPID" if we put only PARAMCD and AVISITN as a filter_spec.
ADLB <- synthetic_cdisc_data("latest")$adlb
keys <- c("STUDYID", "USUBJID", "PARAMCD", "AVISITN", "ATPTN", "DTYPE", "ADTM", "LBSEQ", "ASPID")
ANL1 <- ADLB %>%
filter(PARAMCD == "CRP" & AVISITN == "-1") %>%
select(keys, -PARAMCD, -AVISITN, AVAL1 = AVAL)
ANL2 <- ADLB %>%
filter(PARAMCD == "CRP" & AVISITN == "0") %>%
select(keys, -PARAMCD, -AVISITN, AVAL2 = AVAL)
ANL <- inner_join(ANL1, ANL2, by = c("STUDYID", "USUBJID", "ATPTN", "DTYPE", "ADTM", "LBSEQ", "ASPID"))
Changing the keys only will result in:
- Current apps which are created with
PARAMCDand/orAVISITfilter_specmight fail because output ANL will be merged on a columns which have a different values across the subjects. One can run above code and see that the result of inner_join is empty data.frame. Also our problem is that GDSR keys are not the same what we think they are. Some of the keys in the datasets does not make any row unique adding them - which means that for us they are just values. For exampleAVISITNis a number of a patient visit whileADTMcan be a data of the visit. This means that addingADTMto the keys does not make any row unique, becauseSTUDYID,USUBJID,PARAMCDandAVISITNmake them unique already.
ADLB %>%
group_by(STUDYID, USUBJID, PARAMCD, AVISIT) %>%
summarize(n = n()) %>%
.$n
Above is not the case of our sample datasets only, but might occur also in real data see the issue.
- In case of merging selectors from the same dataset we need to add filter_spec for all of them with
drop_keys = TRUEto avoid cartesian join.
Because keys/data_merge have been problematic since introduction, we need to simplify the way to handle them before reaching wider users base.
Proposition
Change the keys in teal according to GDSR and implement merge module to visualize the join keys.
See a [good example]](https://help.tableau.com/current/pro/desktop/en-us/joining_tables.htm)

Otherwise if we want to keep tea.devel as is we need to fix the documentation to visualize multiple scenarios like:
- multiple single datasets
- reshaping
- mixing datasets
- drop_keys = TRUE consequences
Current documentation in my opinion is not sufficient.
- Lingua principale
- R
- Stelle
- 2
- Fork
- 5
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pharmaverse/teal.transform
-
`data_extract_filter_srv()` drops `filter$sep` when recomputing choices, so multi-variable `filter_spec` loses its selectionForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
pharmaverse/teal.transform#297 ·
-
bug core
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
pharmaverse/teal.transform#281 · 1 reazione ·
-
core enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
pharmaverse/teal.transform#280 ·
-
[Bug]: ordering of selected in choices_selected is not respectedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug core
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
pharmaverse/teal.transform#267 · 3 commenti ·
-
bug core
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
pharmaverse/teal.transform#262 ·
Tutte le issue di pharmaverse/teal.transform
Issue simili
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothApertaarea/ode-pde good first issue help wanted kind/contract severity/4-minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Apich-Organization/rssn#383 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PRL-PRG/r-compile-server#70 · 1 commento ·
-
dependencies docker enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
posit-dev/images-workbench#257 ·
I maintainer di solito rispondono entro 1 giorno
-
dependencies docker enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
posit-dev/images-package-manager#188 ·
I maintainer di solito rispondono entro 1 giorno
-
dependencies docker enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
posit-dev/images-connect#222 ·
I maintainer di solito rispondono entro 1 giorno