MiDataSample: Select matrix columns based on values of attendant vector

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/MiDataSample.R

Description

This function selects columns of a matrix that correspond to 1 or 2 factor levels of attendant vector.

Usage

1
MiDataSample(Matrix, specimens, group1, group2 = NULL)

Arguments

Matrix

matrix

specimens

factor vector with length equal to number of Matrix columns

group1

value of factor level to sample

group2

additional value of factor level to sample

Details

This function is ment for sampling specimens in gene/transcript expression matrix for binary classification in case when specimens belong to more than two groups. The aim is to create gene/transcript expression matrix that contains specimens for only 1 or 2 groups. Groups are specified in corresponding factor vector that contains specimens description. It should be used together with MiSpecimenSample that samples specimens' description in the same way.

Value

Matrix with rescricted number of columns that correspond to specimens from 1 or 2 groups.

Author(s)

Elena N. Filatova

See Also

MiSpecimenSample

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#get gene expression and specimen data
data("IMexpression");data("IMspecimen")
dim(IMexpression) # 100 columns (genes/transcripts) - 89 specimens
colnames(IMexpression)[1:10] # look at first 10 columns of matrix - specimens IDs
IMspecimen[1:10,] # specimens IDs and group factor - diagnoses in attendant vector
# note that specimens in matrix columns are in the same order as specimens in description data
# select specimens with only EBV and NORM diagnoses (and sample the description data as well)
SampleMatrix<-MiDataSample(IMexpression, IMspecimen$diagnosis, "ebv", "norm")
SampleSamples<-MiSpecimenSample(IMspecimen$diagnosis, "ebv", "norm")
dim(SampleMatrix)# only 68 specimens with EBV and NORM diagnoses left
colnames(SampleMatrix)[1:10]
SampleSamples[1:10] # corresponding diagnoses

MiDA documentation built on May 2, 2019, 4:06 p.m.

Related to MiDataSample in MiDA...