Assignment 1/CrossObject.rb
###### METHODS ######
###### 1. INSTANCE METHOD: for checking if there is linckage between genes ######
METHODS
1. INSTANCE METHOD: for checking if there is linckage between genes
METHODS 1 . INSTANCE METHOD : for checking if there is linckage between genes
def checking_linckage()
    total_sum = @F2wild.to_f + @F2P1.to_f + @F2P2.to_f + @F2P1P2.to_f
    expected_F2wild = 9.0/16.0*total_sum.to_f
    expected_F2P1 = 3.0/16.0*total_sum.to_f
    expected_F2P2 = 3.0/16.0*total_sum.to_f
    expectedF2P1P2 = 1.0/16.0*total_sum.to_f
    chi_square = ((@F2wild.to_f - expected_F2wild)**2/expected_F2wild)+((@F2P1.to_f - expected_F2P1)**2/expected_F2P1)+((@F2P2.to_f - expected_F2P2)**2/expected_F2P2)+((@F2P1P2.to_f - expectedF2P1P2)**2/expectedF2P1P2)
    if chi_square > 7.815
        puts "Recording: #{@parent1.geneid.genename} is genetically linked to #{@parent2.geneid.genename} with chisquare score #{chi_square}"
    end
  end
def checking_linckage ( ) total_sum = @F2wild . to_f + @F2P1 . to_f + @F2P2 . to_f + @F2P1P2 . to_f expected_F2wild = 9.0 / 16.0 * total_sum . to_f expected_F2P1 = 3.0 / 16.0 * total_sum . to_f expected_F2P2 = 3.0 / 16.0 * total_sum . to_f expectedF2P1P2 = 1.0 / 16.0 * total_sum . to_f chi_square = ( ( @F2wild . to_f - expected_F2wild ) ** 2 / expected_F2wild ) + ( ( @F2P1 . to_f - expected_F2P1 ) ** 2 / expected_F2P1 ) + ( ( @F2P2 . to_f - expected_F2P2 ) ** 2 / expected_F2P2 ) + ( ( @F2P1P2 . to_f - expectedF2P1P2 ) ** 2 / expectedF2P1P2 ) if chi_square > 7.815 puts "Recording: #{@parent1.geneid.genename} is genetically linked to #{@parent2.geneid.genename} with chisquare score #{chi_square}" end end
METHODS
1.
METHODS 1 .
# must apply a chi-square test to check the linckage between genes # calculating the total real number of descendents  # calculating expected observations # chi-square value (following chi-square formula) # chi-square value por p < 0.05