Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ehr/resources/reports/schemas/study/Pedigree/Pedigree.r
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -200,17 +201,19 @@ 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)
ped$Sire[i] <- paste (ped$Sire[i], "Unknown Sire", sep="\n")
#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);
Expand Down Expand Up @@ -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();
}
};
};