View source: R/geneFoldChange.R
geneFoldChange | R Documentation |
This function will mask a statistic vector into a target and contrast region (default, contrast is the whole vector). Then, the mean gene expression energy in both target and contrast region is calculated, and its quotient (preferential gene expression in target vs contrast) is returned.
geneFoldChange( stats, gene, maskvector = NULL, mask = NULL, tgt.thresh, cntrst.thresh = NULL, checkOrientation = TRUE )
stats |
1-D vector or MINC filename whose values will define the target and contrast regions. It is recommended that you provide a 1D vector instead of a filename, though the code will work regardless. If you are providing a filename, make sure it is in MINC orientation (X=Left-to-Right, Y=Posterior-to-Anterior, Z=Inferior-to-Superior). This is usually the case with files produced with MINC Tools. |
gene |
1-D vector (same length as that of statsvector) or filename of gene expression data (raw format). It is recommended that you provide a 1D vector instead of a filename, though the code will work regardless. If you are providing a filename, make sure it is in ABI orientation X=Anterior-to-Posterior, Y=Superior-to-Inferior, and Z=Left-to-Right. This is usually the case when you download Allen Data. |
maskvector |
mask for both stats and gene, for which elements to analyze. If filenames are provided for stats and gene, mask must be in MINC orientation. Vector Elements are either TRUE or FALSE and vector length must be the same as length of statsvector. DEFAULT: all elements are TRUE, ie. all elements in statsvector and gene are analyzed. |
tgt.thresh |
threshold for target regions (statsvector>tgt.thresh form the target region) |
cntrst.thresh |
threshold for contrast regions (statsvector<=crst.thresh form the contrast region). DEFAULT: contrast includes all the elements in the mask |
checkOrientation |
should I check orientation. You should only turn this off if you know for sure that stats, gene, and mask are in the same orientation (either all ABI or all MINC). |
Fold-Change between mean expression in the target and contrast regions
# I included several files in this package for this example: # The raw gene expression energy files for Nrp1 (http://api.brain-map.org/grid_data/download/74272479) nrp1Filename=system.file('extdata/Nrp1_P56_coronal_74272479_200um.zip',package="ABIgeneRMINC") # Allen Brain Institute annotations (http://download.alleninstitute.org/informatics-archive/current-release/mouse_annotation/P56_Mouse_gridAnnotation.zip) annotFilename=system.file('extdata/P56_Mouse_gridAnnotation.zip',package="ABIgeneRMINC") # T-statistics mincfiles comparing neuroanatomical volumes of mice raised in enriched environments vs standard lab cages. statFilename=system.file('extdata/enrichment_stats.mnc',package="ABIgeneRMINC") # # The following example calculates the foldchange between Nrp1 expression # in significantly larger neuroanatomy (t-statistics > 2) verses the whole brain. # Read gene file and rotate it to MINC orientation nrp1expr=allenVectorTOmincVector(read.raw.gene(nrp1Filename)) # Read stats file stats=RMINC::mincGetVolume(statFilename) # Read annotations, rotate it to MINC orientation, and binarize to make a brain maskvector annotations=allenVectorTOmincVector(read.raw.gene(annotFilename)) maskvector=annotations>0 ; attributes(maskvector) = attributes(annotations) # Foldchange of Nrp1 expression in target (regions with stats>2) vs contrast (whole brain) geneFoldChange(stats,nrp1expr,maskvector,tgt.thresh=2) # 2.072129 # Foldchange of Nrp1 expression in target (regions with stats>2) vs contrast (regions with stats<=0.5 ) geneFoldChange(stats,nrp1expr,maskvector,tgt.thresh=2,cntrst.thresh=0.5) # 2.415599 # # Foldchange of Nrp1 expression in target (regions with stats>2) vs contrast (whole brain) # using strings with filenames instead of 1-D vectors geneFoldChange(statFilename,nrp1Filename,mask = annotFilename,tgt.thresh=2) # 2.072129
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.