Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable rev-comp to deal with indel alleles (esp when using MASHR dbs) #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions Software/PrediXcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ def __init__(self, beta_file, sample_file, gene_file=None):
self.beta_file = beta_file
self.gene_file = gene_file
self.sample_file = sample_file
self.complements = {"A":"T","C":"G","G":"C","T":"A"}
# self.complements = {"A":"T","C":"G","G":"C","T":"A"}

def reverse_complement(self,seq):
complement = {"A":"T","C":"G","G":"C","T":"A"}
reversedseq = "".join(complement.get(base, base) for base in reversed(seq))
return reversedseq
def get_gene_list(self):
if self.gene_file:
return list(sorted([line.strip().split()[-1] for line in open(self.gene_file)]))
Expand All @@ -101,7 +105,7 @@ def update(self, gene, weight, ref_allele, allele, dosage_row):
self.gene_index = { gene:k for (k, gene) in enumerate(self.gene_list) }
self.D = np.zeros((len(self.gene_list), len(dosage_row))) # Genes x Cases
if gene in self.gene_index: #assumes dosage coding 0 to 2
if ref_allele == allele or self.complements[ref_allele] == allele: # assumes non-ambiguous SNPs to resolve strand issues:
if ref_allele == allele or self.reverse_complement(ref_allele) == allele: # assumes non-ambiguous SNPs to resolve strand issues:
self.D[self.gene_index[gene],] += dosage_row * weight
else:
self.D[self.gene_index[gene],] += (2-dosage_row) * weight # Update all cases for that gene
Expand Down