daler / erythroid-genes Goto Github PK
View Code? Open in Web Editor NEWDocuments the construction of mouse erythroid gene lists
License: MIT License
Documents the construction of mouse erythroid gene lists
License: MIT License
def get_human_genes(ids):
"""
Given a list of MyGene.info IDs:
- Query MyGene.info to retrieve Homologene entries
- extract human homologs from the Homologene results
- re-query MyGene.info using the human homologs, and attach
additional fields
- return the human homolog dataframe
If `ids` is a DataFrame, then use the `_id` field. Otherwise
expect a list of MyGene.info IDs.
"""
if isinstance(ids, pandas.DataFrame):
ids = list(ids._id)
# Just ask for the homologene genes
results = mg.querymany(
ids,
fields='homologene.genes',
species='mouse',
as_dataframe=True,
verbose=False,
)
# Homologene results come back as lists of items. Multiple orthologs
# from the same species will manifest as multiple entries in the list.
human_orthologs = []
human_taxon_id = 9606
for x in results['homologene.genes']:
if isinstance(x, list):
for i in x:
if i[0] == human_taxon_id:
human_orthologs.append(i[1])
# Re-query, using the human genes.
return mg.querymany(
human_orthologs,
species='human',
fields='symbol,name,alias,entrezgene,ensembl.gene',
as_dataframe=True,
verbose=False)
found_in_both = li[li._id.isin(hughes._id)]
found_in_either = pandas.concat((li, hughes)).drop_duplicates('_id')
human_found_in_both = get_human_genes(found_in_both)
human_found_in_either = get_human_genes(found_in_either)
human_li = get_human_genes(li)
human_hughes = get_human_genes(hughes)
def export_gene_lists(df, label, prefix='gene-lists/',
fields=['_id', 'entrezgene', 'ensembl.gene', 'symbol', 'alias']):
"""
For each of the specified fields, creates a new file named after
the pattern
<prefix><label>-<field>.txt
containing the unique set of identifiers for that field.
"""
for field in fields:
filename = prefix + label + '-' + field + '.txt'
df2 = df[field].dropna()
with open(filename, 'w') as fout:
for i in df2:
if isinstance(i, list):
i = i = '|'.join(i)
fout.write('%s\n' % i)
import os
if not os.path.exists('gene-lists'):
os.makedirs('gene-lists')
KeyError: 'homologene.genes'
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.