From b0a8c314b021a11b334cd7533f938b46c05a9bfb Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Thu, 29 Apr 2021 15:05:24 -0700 Subject: [PATCH] Omit pedigree plot generations where both dam and sire are unknown --- .../reports/schemas/study/Pedigree/Pedigree.r | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ehr/resources/reports/schemas/study/Pedigree/Pedigree.r b/ehr/resources/reports/schemas/study/Pedigree/Pedigree.r index 5b51f09ce..b9b6386b6 100644 --- a/ehr/resources/reports/schemas/study/Pedigree/Pedigree.r +++ b/ehr/resources/reports/schemas/study/Pedigree/Pedigree.r @@ -15,8 +15,7 @@ library(Rlabkey) labkey.setCurlOptions(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE) - -if ((length(labkey.data$id) == 0) || all(is.na(labkey.data$dam) & is.na(labkey.data$sire))) { +if ((length(labkey.data$id) == 0) | (is.na(labkey.data$dam) & is.na(labkey.data$sire))){ png(filename="${imgout:myscatterplot}", width = 650, height = 150); plot(0, 0, type='n', xaxt='n', yaxt='n', bty='n', ann=FALSE ) title(main = "No pedigree data found for selected animal(s).", sub = NULL, xlab = NULL, ylab = NULL, @@ -185,6 +184,8 @@ if ((length(labkey.data$id) == 0) || all(is.na(labkey.data$dam) & is.na(labkey.d return (substr(lineNL, 1, nchar(lineNL) - 1)); }; + unknownIdIndex = 1 + #[Quoc: remove ] #The pedigree program expects all individuals to have either 2 parents or 1. #Sometimes the father is not known. For missing parents we give them a unique id and @@ -200,8 +201,9 @@ if ((length(labkey.data$id) == 0) || all(is.na(labkey.data$dam) & is.na(labkey.d if (length(damIndex) == 0) damIndex <- which(allPed$Id == ped$Dam[i]); if (length(sireIndex) == 0) sireIndex <- which(allPed$Id == ped$Sire[i]); - if(is.na(ped$Sire[i])){ - xt <- sample (1:99,1) + if((is.na(ped$Sire[i]))& (!is.na(ped$Dam[i]))){ + xt <- unknownIdIndex + unknownIdIndex <- unknownIdIndex + 1 #typeof(ped$Sire); #typeof(xt); ped$Sire[i] <- paste('xxs',xt) @@ -209,8 +211,9 @@ if ((length(labkey.data$id) == 0) || all(is.na(labkey.data$dam) & is.na(labkey.d #print(ped$Dam[i]) #print(ped$Sire[i]) } - if(is.na(ped$Dam[i])){ - xt <- sample (1:99,1) + if((is.na(ped$Dam[i]))& (!is.na(ped$Sire[i]))){ + xt <- unknownIdIndex + unknownIdIndex <- unknownIdIndex + 1 #typeof(ped$Sire); #typeof(xt); ped$Dam[i] <- paste ('xxd',xt); @@ -302,4 +305,4 @@ if ((length(labkey.data$id) == 0) || all(is.na(labkey.data$dam) & is.na(labkey.d legend(x = "bottomright", legend=leg.txt, pch=c(0, 1, 47), col=c('blue', 'red', 'black'), inset = 0.1, cex=1, pt.cex = 1.8) #dev.off(); } -}; \ No newline at end of file +};