Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 8 additions & 11 deletions Pedigree.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, idx, idn, MetaFounder=None) :

self.genotypedFounderStatus = None #?

self.MetaFounder = MetaFounder
self.MetaFounder = [MetaFounder] if MetaFounder is not None else None

self.phenotype = None

Expand Down Expand Up @@ -536,7 +536,7 @@ def readInPedigreeFromList(self, pedList):

# check if the individual is a metafounder
if idx is not None and idx[:3] == "MF_":
print(f"ERROR: Invalid metafounder input format.\nExiting...")
print(f"ERROR: Individual {idx} uses the prefix 'MF_' which is reserved for metafounders and cannot be used for an individual's id. \nExiting...")
sys.exit(2)

# All individuals (and dummy individuals) in the pedigree are assigned the default metafounder.
Expand Down Expand Up @@ -574,14 +574,11 @@ def readInPedigreeFromList(self, pedList):
# check if the metafounders match
if sireID == damID:
# Overwrite the default metafounder.
ind.MetaFounder = sireID
ind.MetaFounder = [sireID]
else:
# expect more infomative error message
print(f"ERROR: Invalid metafounder input format.\nExiting...")
sys.exit(2)
ind.MetaFounder = [sireID, damID]
else:
# expect more infomative error message
print(f"ERROR: Invalid metafounder input format.\nExiting...")
print(f"ERROR: Both parents must be metafounders if one is a metafounder. For individual {idx} the parents were {sireID} and {damID}.\nConsider using a dummy individual for the metafounder.\nExiting...")
sys.exit(2)
else:
if sireID is None:
Expand Down Expand Up @@ -1010,7 +1007,7 @@ def readInAAP(self, fileName):
mfx, data = value
nLoci = self.nLoci
if len(data) != nLoci:
print("ERROR: Incorrect alternative allele probability input format. \nExiting...")
print(f"ERROR: For {mfx}, not all loci have an alternative allele frequency in the `-alt_allele_prob_file` input. \nExiting...")
sys.exit(2)
if mfx[:3] == "MF_":
if mfx == MainMetaFounder:
Expand All @@ -1019,11 +1016,11 @@ def readInAAP(self, fileName):
try:
current_aap[:] = data
except ValueError:
print("ERROR: Incorrect alternative allele probability input format. \nExiting...")
print(f"ERROR: For {mfx}, the alternative allele frequency data gave a ValueError. Please check the `-alt_allele_prob_file` input. \nExiting...")
sys.exit(2)
self.AAP[mfx] = current_aap
else:
print("ERROR: Incorrect alternative allele probability input format. \nExiting...")
print(f"ERROR: All metafounders must have the prefix 'MF_'. {mfx} does not but is present in the `-alt_allele_prob_file`. Please remove or rename {mfx}. \nExiting...")
sys.exit(2)

if default_aap:
Expand Down
15 changes: 15 additions & 0 deletions ProbMath.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ def getGenotypesFromMaf(maf) :

return mafGenotypes

def getGenotypesFromMultiMaf(mafDict) :
nLoci = len(mafDict[list(mafDict.keys())[0]])
mafGenotypes = np.full((4, nLoci), .25, dtype = np.float32)
# Assumes two maf inputs.
# maf1 from the sire, maf2 from the dam.
maf1 = mafDict[list(mafDict.keys())[0]]
maf2 = mafDict[list(mafDict.keys())[1]]

mafGenotypes[0,:] = (1-maf1)*(1-maf2)
mafGenotypes[1,:] = (1-maf1)*(maf2)
mafGenotypes[2,:] = (maf1)*(1-maf2)
mafGenotypes[3,:] = maf1*maf2

return mafGenotypes

def getGenotypeProbabilities_ind(ind, args = None, log = False):
if args is None:
error = 0.01
Expand Down