Input/output utilities¶
Input/output utilities.
- anhima.io.save_tped(path, genotypes, ref, alt, pos, chromosome=u'0', identifier=None, genetic_distance=None)[source]¶
Write biallelic diploid genotype data to a file using the Plink transposed format (TPED).
Parameters: path : string or file-like
Path of file to write, or file-like object to write to.
genotypes : array_like, int
An array of shape (n_variants, n_samples, 2) where each element of the array is an integer corresponding to an allele index (-1 = missing, 0 = reference allele, 1 = first alternate allele, etc.).
ref : array_like, string
A 1-dimensional array of single character strings encoding the reference nucleotide.
alt : array_like, string
A 1-dimensional array of single character strings encoding the alternate nucleotide.
pos : array_like, int
A 1-dimensional array of genomic positions.
chromosome : string or array_like, string, optional
Either a single string (if all variants are from the same chromosome/contig) or an array of strings with the chromosome of each variant.
identifier : array_like, string, optional
An array of SNP identifiers. If not provided, identifiers will be created based on the variant position, e.g., ‘snp100042’, ‘snp100081’, etc.
genetic_distance : array_like, float
An array of genetic distances. If not provided, a zero value (‘0’) will be written for all variants.