Learn R Programming

rnaseqWrapper (version 1.0-1)

calcHornMatrix: Calculate a Horn distance matrix

Description

This function calculates the pairwise Horn distance between samples based on relative presence of observed variables.

Usage

calcHornMatrix(inputTable)

Arguments

inputTable
A matrix or data.frame of relative frequencies of whatever is being measured. Each row is a variable (e.g. gene) and each column is a sample (e.g. individual). The algorithm expects each column to sum to 1. That is, each entry should be the portion of observations (e.g. reads) representing the variable (gene) from the total observations for a sample (individual).

Value

Returns a matrix of pair-wise similarity scores for each column.

References

This was (heavily) modified from a script provided by a collaborator of Gina Lamendella's. I need to get more information

Examples

Run this code

## Only run if DESeq is available
if(require(DESeq)){

## Create sample counts
## Thes could be the reads or FPKM from input data instead
require(DESeq)
exampleCounts <- counts(makeExampleCountDataSet())

testHorn <- calcHornMatrix(exampleCounts)
head(testHorn)


## Plot the results
distMat <-as.dist( (1-testHorn), diag=FALSE, upper=FALSE)

# scores to plot MDS (ecodist)
scores_ADNA <-nmds(distMat, mindim=2, maxdim=2) 
scores_ADNA <- nmds.min(scores_ADNA)

# Set colors to match treatments
treatCol <- c("red","red","blue","blue","blue")

plot(scores_ADNA[,1:2],pch=19,col=treatCol)

}

Run the code above in your browser using DataLab