mayoverse / kinship2

Pedigree creation, plotting, and analytics
GNU General Public License v2.0
13 stars 7 forks source link

More permissive pedigree #16

Open courtiol opened 1 year ago

courtiol commented 1 year ago

For some applications, it could be useful to have plot with diamonds in the middle of the tree.

For example, I want to represent any grand mother - grand mother relationship, irrespective of whether the gdma is a maternal or paternal gdma:

To do that I had to hack a couple of checks within the pedigree function:

if(any(!sex[findex] %in% c("male", "unknown"))) {
   who <- unique((id[findex])[!sex[findex] %in% c("male", "unknown")])
   msg.n <- 1:min(5, length(who))  #Don't list a zillion
   stop(paste("Id not male (or unknown), but is a father:", 
            paste(who[msg.n], collapse= " ")))
    }

instead of: https://github.com/mayoverse/kinship2/blob/ba65a5fb57003e480ef5e842add7f8b839d12b2b/R/pedigree.R#L121-L126

and

if(any(!sex[mindex] %in% c("female", "unknown"))) {
    who <- unique((id[mindex])[!sex[mindex] %in% c("female", "unknown")])
    msg.n <- 1:min(5, length(who))
    stop(paste("Id not female (or unknown), but is a mother:", 
               paste(who[msg.n], collapse = " ")))
    }

instead of: https://github.com/mayoverse/kinship2/blob/ba65a5fb57003e480ef5e842add7f8b839d12b2b/R/pedigree.R#L136-L141

I understand that it should not be the default behavior, but if an option could allow for this to happen, that would be great since the plotting function seems to have no difficulty with this (although I did not test extensively).

sinnweja commented 11 months ago

You are certainly welcome to take the code and make your own edits for these use cases. However, the diamond is a reserved symbol for a missing sex in the pedigree (sex code of 3).

diamond_symbol

courtiol commented 11 months ago

Dear @sinnweja , I don't think you understand me. I did not change the meaning of the diamond, it is still used to display a missing sex. The point was to allow for individuals of missing sex to be parents.

sinnweja commented 11 months ago

My apologies. Now I see your point, and indeed we have had a few requests to lift this check when plotting asexual generations. We will try to incorporate this as an option.