In [9]:
# settings and modules
%config InlineBackend.figure_format = 'retina'
%pylab inline
from nsaba.nsaba import nsaba
from nsaba.nsaba import visualizer
from nsaba.nsaba import analysis
from nsaba.nsaba import geneinfo
NSABA (NeuroSynth Allen Brain Atlas) is a python module with a suite of tools for analyzing fMRI meta-analyses from Neurosynth (http://neurosynth.org) and brain-wide, genome-scale human gene experession data from the Allen Brain Institute (http://human.brain-map.org/)
This tool can be used to estimate gene expression or term association with given coordinates, visualize relationships between gene expression and term association, and perform several analyses on these data
In other words, this tool can ask questions such as, "Is the D2 receptor expressed significantly higher in brain regions that are activated in studies that talk about 'reward'?" Moreover, this tool can be used to algorithmically generate novel hypotheses about genes and functional networks
This notebook will demonstrate some of the functionality of the Nsaba toolbox to explore the relationship between D2 receptors and parts of the brain associated with reward. This is the short demo. For a more in-depth walkthrough, see the Long Demo notebook in this Repo.
In [7]:
#local paths to data
ns_path = "/Users/Torben/Documents/ABI analysis/current_data_new/"
aba_path = '/Users/Torben/Documents/ABI analysis/normalized_microarray_donor9861/'
#initialization methods
nsaba.Nsaba.ns_load(ns_path)
nsaba.Nsaba.aba_load(aba_path)
#Creating Nsaba object and loading previously estimated gene activation values
N = nsaba.Nsaba()
N.load_ge_pickle(pkl_file='/Users/Torben/Documents/ABI analysis/normalized_microarray_donor9861/Nsaba_ABA_ge.pkl')
# * 'Reward': term used to describe behaviors associated with basal ganglia circuitry
# * entrez ID: 1813 - DRD2, the gene that encodes the D2 dopamine receptor
term1 = 'reward'
genes = [1813 , 6531]
N.estimate_ns_act(term1)
In [10]:
V = visualizer.NsabaVisualizer(N)
V.visualize_ge([genes[0]])
V.visualize_ns('reward',no_ids = 20)
gene_info_output = geneinfo.get_local_gene_info('/Users/Torben/Code/nsaba/csv/',[genes[0]])
for info in gene_info_output:
print info,'\n'
In [11]:
radius = 10
rnn_args = dict();
rnn_args['radius']= radius
custom_coords = [(-10,20,1),(-4,21,10),(23,11,-6),(10,-20,-3),(-11,8,-20)]
N.estimate_aba_ge(entrez_ids = genes,coords=custom_coords,store_coords=True,z_score=True)
mean_expression_at_coords = N.ge[1813]['mean']['GE']
print 'Estimation of DRD2 gene expression at custom coordinates: '+ str(mean_expression_at_coords)
N.estimate_ns_act(term='reward',coords=custom_coords)
reward_estimation = N.term['reward']['act']
print 'Estimation of reward at custom coordinates: '+ str(reward_estimation)
In [15]:
N.load_ge_pickle(pkl_file='/Users/Torben/Documents/ABI analysis/normalized_microarray_donor9861/Nsaba_ABA_ge.pkl')
N.estimate_ns_act('reward')
A = analysis.NsabaAnalysis(N)
A.term_ge_ttest('reward',genes[0],graphops='violin',quant = 90)
In [16]:
ttest_metrics = A.term_ge_ttest_multi('reward',quant=90)
A.cohen_d_distr(ttest_metrics,genes_of_interest=genes)
In [7]:
top_genes = A.fetch_gene_descriptions(ttest_metrics,csv_path='/Users/Torben/Code/nsaba/csv/')