Description Objects from the Class Slots Extends Methods Note Author(s) See Also Examples
This class defines objects holding large arrays of single nucleotide polymorphism (SNP) genotypes generated using array technologies.
Objects can be created by calls of the form new("SnpMatrix", x)
where x
is a matrix with storage mode "raw"
.
Chips (usually corresponding to samples or
subjects) define rows of the matrix while polymorphisms (loci) define
columns. Rows and columns will usually have names which can be
used to link the data to further data concerning samples and SNPs
.Data
:Object of class "matrix"
and storage
mode raw
Internally, missing data are coded 0 and SNP genotypes are coded
1, 2 or 3. Imputed values may not be known exactly. Such
uncertain calls are grouped by probability and represented by codes
4 to 253
Class "matrix"
, from data part.
Class "structure"
, by class "matrix"
.
Class "array"
, by class "matrix"
.
Class "vector"
, by class "matrix", with explicit coerce.
Class "vector"
, by class "matrix", with explicit coerce.
signature(x = "SnpMatrix", i = "ANY", j = "ANY",
drop = "missing")
: subset
operations
signature(x = "SnpMatrix", y = "SnpMatrix")
:
S4 generic function to provide cbind() for two or
more matrices together by column. Row names must match and column
names must not coincide. If the matrices are of the derived class
XSnpMatrix-class
, the diploid
slot values must also
agree
signature(from = "SnpMatrix", to = "numeric")
:
map to numeric values 0, 1, 2 or, for uncertain assignments, to
the posterior expectation of the 0, 1, 2 code
signature(from = "SnpMatrix", to =
"character")
: map to codes "A/A", "A/B", "B/B", ""
signature(from = "matrix", to = "SnpMatrix")
:
maps numeric matrix (coded 0, 1, 2 or NA) to a SnpMatrix
signature(from = "SnpMatrix", to =
"XSnpMatrix")
:
maps a SnpMatrix to an XSnpMatrix. Ploidy is inferred from the
genotype data since haploid genotypes should always be coded as
homozygous.
After inferring ploidy, heterozygous calls for haploid genotypes
are set to NA
signature(x = "SnpMatrix")
: returns a logical
matrix indicating whether each element is NA
signature(x = "SnpMatrix", y = "snp.matrix")
:
S4 generic function to provide rbind() for two or
more matrices by row. Column names must match and duplicated row
names prompt warnings
signature(object = "SnpMatrix")
: shows the size
of the matrix (since most objects will be too large to show in full)
signature(object = "SnpMatrix")
: returns
summaries of the data frames returned by
row.summary
and col.summary
signature(x = "SnpMatrix")
: returns a logical
matrix of missing call indicators
signature(x = "SnpMatrix", snps
="ANY")
: Recode specified columns of of the matrix to reflect
allele switches
This class requires at least version 2.3 of R
David Clayton dc208@cam.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | data(testdata)
summary(Autosomes)
# Just making it up - 3-10 will be made into NA during conversion
snps.class<-new("SnpMatrix", matrix(1:10))
snps.class
if(!isS4(snps.class)) stop("constructor is not working")
pretend.X <- as(Autosomes, 'XSnpMatrix')
if(!isS4(pretend.X)) stop("coersion to derived class is not S4")
if(class(pretend.X) != 'XSnpMatrix') stop("coersion to derived class is not working")
pretend.A <- as(Xchromosome, 'SnpMatrix')
if(!isS4(pretend.A)) stop("coersion to base class is not S4")
if(class(pretend.A) != 'SnpMatrix') stop("coersion to base class is not working")
# display the first 10 snps of the first 10 samples
print(as(Autosomes[1:10,1:10], 'character'))
# convert the empty strings (no-calls) explicitly to "NC" before
# writing to an (anonymous and temporary) csv file
csvfile <- tempfile()
write.csv(file=csvfile, gsub ('^$', 'NC',
as(Autosomes[1:10,1:10], 'character')
), quote=FALSE)
unlink(csvfile)
|
Loading required package: survival
Loading required package: Matrix
$rows
Call.rate Certain.calls Heterozygosity
Min. :0.6577 Min. :1 Min. :0.2182
1st Qu.:0.6963 1st Qu.:1 1st Qu.:0.2550
Median :0.9455 Median :1 Median :0.2599
Mean :0.8657 Mean :1 Mean :0.2598
3rd Qu.:0.9628 3rd Qu.:1 3rd Qu.:0.2642
Max. :0.9781 Max. :1 Max. :0.2820
$cols
Calls Call.rate Certain.calls RAF
Min. : 0.0 Min. :0.0000 Min. :1 Min. :0.0000
1st Qu.:265.0 1st Qu.:0.6625 1st Qu.:1 1st Qu.:0.1610
Median :394.0 Median :0.9850 Median :1 Median :0.4775
Mean :346.3 Mean :0.8657 Mean :1 Mean :0.4882
3rd Qu.:398.0 3rd Qu.:0.9950 3rd Qu.:1 3rd Qu.:0.8166
Max. :400.0 Max. :1.0000 Max. :1 Max. :1.0000
NA's :43 NA's :43
MAF P.AA P.AB P.BB
Min. :0.0000 Min. :0.00000 Min. :0.00000 Min. :0.00000
1st Qu.:0.0325 1st Qu.:0.03275 1st Qu.:0.06172 1st Qu.:0.02506
Median :0.1713 Median :0.26984 Median :0.28444 Median :0.22822
Mean :0.1920 Mean :0.38189 Mean :0.25975 Mean :0.35836
3rd Qu.:0.3289 3rd Qu.:0.70551 3rd Qu.:0.43609 3rd Qu.:0.66582
Max. :0.5000 Max. :1.00000 Max. :1.00000 Max. :1.00000
NA's :43 NA's :43 NA's :43 NA's :43
z.HWE
Min. :-19.9499
1st Qu.: -0.5980
Median : 0.0754
Mean : -0.0197
3rd Qu.: 0.6803
Max. : 16.2481
NA's :1254
coercing object of mode numeric to SnpMatrix
object has no names - using numeric order for row/column names
A SnpMatrix with 10 rows and 1 columns
Row names: 1 ... 10
Col name: 1
Warning message:
In initialize(value, ...) :
diploid slot not supplied; it has been estimated from heterozygosity
173760 173761 173762 173767 173769 173770 173772 173774 173775 173776
1987 "A/A" "A/A" "A/A" "B/B" "B/B" "B/B" "B/B" "A/B" "A/A" "A/A"
436 "A/A" "B/B" "B/B" "B/B" "B/B" "B/B" "B/B" "B/B" "A/A" "A/A"
762 "A/A" "A/B" "A/B" "A/B" "B/B" "B/B" "B/B" "A/B" "A/A" "A/A"
1199 "A/A" "A/B" "A/B" "A/A" "B/B" "B/B" "B/B" "B/B" "A/A" "A/A"
1296 "A/A" "A/A" "A/A" "A/B" "B/B" "B/B" "B/B" "B/B" "A/A" "A/A"
81 "A/A" "A/B" "A/B" "A/B" "B/B" "B/B" "B/B" "B/B" "A/B" "A/A"
1278 "A/A" "B/B" "B/B" "NA" "B/B" "B/B" "B/B" "B/B" "B/B" "A/A"
1610 "A/A" "A/A" "A/A" "A/B" "A/B" "B/B" "B/B" "A/B" "A/A" "A/A"
1121 "A/A" "A/A" "A/A" "A/A" "B/B" "B/B" "B/B" "B/B" "A/B" "A/B"
1825 "A/A" "A/B" "A/B" "B/B" "B/B" "B/B" "B/B" "B/B" "A/A" "A/A"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.