ARS-toscana / ConcePTIONAlgorithmPregnancies

Repository of the script of the ConcePTION Algorithm for Pregnancies
GNU Affero General Public License v3.0
5 stars 3 forks source link

Problem (and solution) for "Diagnosis" blocks in 04_algorithms_pregnancy.R #38

Closed LAMaglan closed 2 years ago

LAMaglan commented 2 years ago

There is an error when if (concept_set_domains[[conceptset]] == "Diagnosis"){} lines are run in the for loops in "04_algorithms_pregnancy.R" https://github.com/ARS-toscana/ConcePTIONAlgorithmPregnancies/blob/version_3.0/p_parameters_pregnancy/04_algorithms_pregnancy.R

for (conceptset in concept_set_pregnancy){}

(see screenshot) conceptset_error

It seems this is because some of the "conceptset"s do not necessarily exist in concept_set_domains, and therefore throws a logical rather than TRUE/FALSE. One solution is to wrap this in another if block:

if (conceptset %in% names(concept_set_domains)){
   if (concept_set_domains[[conceptset]] == "diagnosis"){
      #do the rest of the code
   }
}

This (or other) solutions needs to be implemented in each of the for loops evaluating "Diagnosis" in "04_algorithms_pregnancy.R" (see screenshot for full example for the first occurrence in line 57) conceptset_fix

GiorgioLimoncella commented 2 years ago

Hello, All "conceptsets" must exist in the "concept_set_domains" list. Can you please run the file "to_run.R" up to line 44 and then type in the console concept_set_pregnancy[concept_set_pregnancy %notin% names(concept_set_domains)] ?

should print out the concepts that are not in concept_set_domains, if you send them to me later I'll try to figure out the problem!

Many thank!

LAMaglan commented 2 years ago

When running: concept_set_pregnancy[concept_set_pregnancy %notin% names(concept_set_domains)] I get: "fetal_nuchal_translucency", "amniocentesis", "Chorionic_Vllus_Sampling", "others". (this is also the cases where a for loop in a later step, step_03_02_T2.2_internal_consistency_for_conceptsets.R gives errors)

GiorgioLimoncella commented 2 years ago

thank you very much, we found the problem, the fixed version is updated in GH.

the files we have modified are the following:

could you please replace them in your folder and run the script again?

thanks again, Giorgio

LAMaglan commented 2 years ago

Great! This problem seems to be fixed - the code you asked me to run now returns nothing (character(0)). It does not seem like these updated scripts were pushed to the github-repo yet (at least in the version_3.0 branch) but received in e-mail.

GiorgioLimoncella commented 2 years ago

you're right, I actually pushed to the wrong branch. Thanks for notifying it I will fix it right away