[BioRuby-cvs] bioruby/lib/bio/util contingency_table.rb,1.5,1.6

Trevor Wennblom trevor at dev.open-bio.org
Sun Dec 31 23:04:07 UTC 2006


Update of /home/repository/bioruby/bioruby/lib/bio/util
In directory dev.open-bio.org:/tmp/cvs-serv32628

Modified Files:
	contingency_table.rb 
Log Message:
Standardized documentation for ContingencyTable to meet README.DEV

Index: contingency_table.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/util/contingency_table.rb,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** contingency_table.rb	31 Dec 2006 20:02:20 -0000	1.5
--- contingency_table.rb	31 Dec 2006 23:04:04 -0000	1.6
***************
*** 249,252 ****
--- 249,257 ----
    # Create a ContingencyTable that has characters_in_sequence.size rows and
    # characters_in_sequence.size columns for each row
+   #
+   # ---
+   # *Arguments*
+   # * +characters_in_sequences+: (_optional_) The allowable characters that will be present in the aligned sequences.
+   # *Returns*:: +ContingencyTable+ object to be filled with values and calculated upon
    def initialize(characters_in_sequences = nil)
      @characters = ( characters_in_sequences or %w{a c d e f g h i k l m n p q r s t v w y - x u} )
***************
*** 256,259 ****
--- 261,269 ----
    
    # Report the sum of all values in a given row
+   #
+   # ---
+   # *Arguments*
+   # * +i+: Row to sum
+   # *Returns*:: +Integer+ sum of row
    def row_sum(i)
      total = 0
***************
*** 263,266 ****
--- 273,281 ----
  
    # Report the sum of all values in a given column
+   #
+   # ---
+   # *Arguments*
+   # * +j+: Column to sum
+   # *Returns*:: +Integer+ sum of column
    def column_sum(j)
      total = 0
***************
*** 273,276 ****
--- 288,295 ----
    # * This is the same thing as asking for the sum of all values in the table.
    #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Integer+ sum of all columns
    def column_sum_all
      total = 0
***************
*** 283,286 ****
--- 302,309 ----
    # * This is the same thing as asking for the sum of all values in the table.
    #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Integer+ sum of all rows
    def row_sum_all
      total = 0
***************
*** 290,296 ****
    alias table_sum_all row_sum_all
  
    #
!   #   e(sub:ij) = (r(sub:i)/N) * (c(sub:j))
!   #
    def expected(i, j)
      (row_sum(i).to_f / table_sum_all) * column_sum(j)
--- 313,323 ----
    alias table_sum_all row_sum_all
  
+   # Calculate _e_, the _expected_ value.
    #
!   # ---
!   # *Arguments*
!   # * +i+: row
!   # * +j+: column
!   # *Returns*:: +Float+ e(sub:ij) = (r(sub:i)/N) * (c(sub:j))
    def expected(i, j)
      (row_sum(i).to_f / table_sum_all) * column_sum(j)
***************
*** 298,301 ****
--- 325,333 ----
  
    # Report the chi square of the entire table
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Float+ chi square value
    def chi_square
      total = 0
***************
*** 310,314 ****
    end
  
!   # Report the chi square relation of two elements in the table
    def chi_square_element(i, j)
      eij = expected(i, j)
--- 342,352 ----
    end
  
!   # Report the chi-square relation of two elements in the table
!   #
!   # ---
!   # *Arguments*
!   # * +i+: row
!   # * +j+: column
!   # *Returns*:: +Float+ chi-square of an intersection
    def chi_square_element(i, j)
      eij = expected(i, j)
***************
*** 318,321 ****
--- 356,364 ----
  
    # Report the contingency coefficient of the table
+   #
+   # ---
+   # *Arguments*
+   # * _none_
+   # *Returns*:: +Float+ contingency_coefficient of the table
    def contingency_coefficient
      c_s = chi_square




More information about the bioruby-cvs mailing list