Question regarding shape of SNPsample
@embray could you please help me to clarify this?
The npz files contain snp matrices stored as individuals x snps
and, as I understand, a SNPsample.snp is also individuals x snps
I hence got very confused with the
def n_snp(self):
"""The number of SNPs in the sample."""
return self.shape[0]
but then realized that shape
on a SNPsample instance was reverting the order of the traditional shape by giving (self._snp.shape[1], self._snp.shape[0])
and the same is true for get_shape
What is the reason for doing this?
code details
@cached_property
def shape(self):
"""The number of SNPs and number of individuals as a tuple."""
if self._snp is not None:
return (self._snp.shape[1], self._snp.shape[0])
else:
return self._loader.get_shape()
@property
def n_snp(self):
"""The number of SNPs in the sample."""
return self.shape[0]
@property
def n_indiv(self):
"""The number of individuals in the sample."""
return self.shape[1]
def get_shape(self):
"""
Returns the dimensions of an `SNPSample` as a tuple of ``(n_snp,
n_indiv)``.
The default implementation simply calls `SNPLoader.get_data` and
returns the dimensions of the tensors. However, this may be overridden
by subclasses to provide a more efficient implementation, e.g. that
does not require loading the full data if there is metadata available
to provide this information.
"""
snp, pos = self.get_data()
return (snp.shape[1], snp.shape[0])