示例#1
0
    def compute_mad_neutral_state(self, df):
        df_neutral_state = df[(df['state'] == 3) & (~df['copy'].isnull())]

        if len(df_neutral_state) > 0:
            mad_neutral_state = stand_mad(df_neutral_state['copy'], c=1)

        else:
            mad_neutral_state = float('NaN')

        return mad_neutral_state
示例#2
0
    def compute_mad_hmmcopy(self, df):
        df_hmmcopy = df[~df['copy'].isnull()]

        if len(df_hmmcopy) > 0:
            mad_hmmcopy = stand_mad(df_hmmcopy['copy'], c=1)

        else:
            mad_hmmcopy = float('NaN')

        return mad_hmmcopy
示例#3
0
    def compute_mad_autosomes(self, df):
        df_autosomes = df[(df['chr'] != 'X') & (df['chr'] != 'Y')]

        if len(df_autosomes) > 0:
            mad_autosomes = stand_mad(df_autosomes['copy'], c=1)

        else:
            mad_autosomes = float('NaN')

        return mad_autosomes
示例#4
0
    def compute_chr_mad_hmmcopy(self, df, chrom):
        df_hmmcopy = df[~df['copy'].isnull()]

        df_chr = df_hmmcopy[df_hmmcopy['chr'] == str(chrom)]

        if len(df_chr) > 0:
            mad_chr = stand_mad(df_chr['copy'], c=1)

        else:
            mad_chr = float('NaN')

        return mad_chr
示例#5
0
 def _estimate_scale(self, resid):
     """
     Estimates the scale based on the option provided to the fit method.
     """
     if isinstance(self.scale_est, str):
         if self.scale_est.lower() == 'mad':
             return scale.mad(resid)
         if self.scale_est.lower() == 'stand_mad':
             return scale.stand_mad(resid)
     elif isinstance(self.scale_est, scale.HuberScale):
         return scale.hubers_scale(self.df_resid, self.nobs, resid)
     else:
         return scale.scale_est(self, resid)**2
示例#6
0
 def _estimate_scale(self, resid):
     """
     Estimates the scale based on the option provided to the fit method.
     """
     if isinstance(self.scale_est, str):
         if self.scale_est.lower() == 'mad':
             return scale.mad(resid)
         if self.scale_est.lower() == 'stand_mad':
             return scale.stand_mad(resid)
     elif isinstance(self.scale_est, scale.HuberScale):
         return self.scale_est(self.df_resid, self.nobs, resid)
     else:
         return scale.scale_est(self, resid)**2
示例#7
0
 def test_axisneg1(self):
     m = scale.stand_mad(self.X, axis=-1)
     assert_equal(m.shape, (40,10))
示例#8
0
 def test_axis1(self):
     m = scale.stand_mad(self.X, axis=1)
     assert_equal(m.shape, (40,30))
示例#9
0
 def test_axis0(self):
     m = scale.stand_mad(self.X, axis=0)
     assert_equal(m.shape, (10,30))
示例#10
0
 def test_stand_mad(self):
     m = scale.stand_mad(self.X)
     assert_equal(m.shape, (10,))
示例#11
0
 def test_stand_mad(self):
     assert_almost_equal(scale.stand_mad(self.chem), 0.52632, DECIMAL)