interpolate.gene: Interpolate Gene Expression

View source: R/interpolate.gene.r

interpolate.geneR Documentation

Interpolate Gene Expression

Description

Missing gene expression data is interpolated with a marching average of nearest neighbours. Neighbours are averaged if they have gene expression. After several iterations it will cover the whole brain.

Usage

interpolate.gene(
  genevec,
  maskvec,
  dimensions = rev(attr(genevec, "sizes")),
  itermax = 1000
)

Arguments

genevec

1D vector of gene expression data. Missing data has value of -1.

maskvec

1D logical vector indicating which elements of genevec to consider for analysis. When function finishes running and converges, all genevec elements within the mask will have positive values.

dimensions

1D integer vector of length 3 specifying array dimensions (fastest to slowest dimensions)

itermax

Maximum number of iterations to run the marching average of nearest neighbours.

Value

1D vector of gene expression data, with missing data interpolated from nearest neighbours.

Examples

# In this example, we will download gene expression of Nrxn1 (Experiment 75988632).
# Missing data will be interpolated using marching average of nearest neighbours
# 
# Download and read Nrxn Data
genetest=read.raw.gene("http://api.brain-map.org/grid_data/download/75988632?include=energy",url=TRUE)

# Read label file and create a mask of elements in the brain
labelfile=system.file('extdata/gridAnnotation.raw',package="ABIgeneRMINC")
mask=read.raw.gene(labelfile,labels=TRUE)>0

# Make image of horizontal slice before interpolation
image(array(genetest,rev(attributes(genetest)$sizes))[,25,],ylab='Left-Right' ,xlab='Anterior-Posterior')
# Make image of sagittal slice before interpolation
image(array(genetest,rev(attributes(genetest)$sizes))[,,25], ylab='Superior-Inferior' ,xlab='Anterior-Posterior')

# Interpolate
interp.gene=interpolate.gene(genetest,mask)

# Make image of horizontal slice after interpolation
image(array(interp.gene,rev(attributes(interp.gene)$sizes))[,25,],ylab='Left-Right' ,xlab='Anterior-Posterior')
# Make image of sagittal slice before interpolation
image(array(interp.gene,rev(attributes(interp.gene)$sizes))[,,25], ylab='Superior-Inferior' ,xlab='Anterior-Posterior')



DJFernandes/ABIgeneRMINC documentation built on March 21, 2022, 12:05 p.m.