Package ru.autosome.commons.motifModel.mono

Examples of ru.autosome.commons.motifModel.mono.PWM


    return new WordwiseBackground();
  }

  @Override
  protected PWM createMotif(double[][] matrix, String name) {
    return new PWM(matrix, name);
  }
View Full Code Here


                                {10.5, -3.0, 0.0, 0.0},
                                {5.0, 5.0, 5.0, -10.0},
                                {0.0, 0.0, 0.0, 0.0},
                                {-1.0, 10.5, -1.0, 0.0},
                                {0.0, 0.0, 0.0, 2.0} };
    PWM pwm_manual_constructed = new PWM(matrix_cAVNCT, "PWM for cAVNCt consensus sequence (name of PWM)");

    pwmCollection.add(pwm_manual_constructed);

    // PWM from PPM
    double[][] ppm_matrix = { {0.2, 0.4, 0.2, 0.2},
                             {0.9, 0, 0.05, 0.05},
                             {0.3, 0.3, 0.3, 0.1},
                             {0.25, 0.25, 0.25, 0.25},
                             {0, 0.9, 0, 0.1},
                             {0.2, 0.2, 0.2, 0.4} };
    PPM ppm = new PPM(ppm_matrix, "cAVNCt PPM (slightly different from another cAVNCt matrix)");
    PWM pwm_from_ppm = ppm.to_pwm(background, ppm_effective_count);
    pwmCollection.add(pwm_from_ppm);

    //////////////////////////////////////////////////////////////////////////////////////////////////

    // Now we should get collection of SNPs with sequence around them. Each SNP should have only two variants (if one need 3 or 4 variants, it's possible to add several SNPs: 1-2, 2-3, 1-3 for instance)
View Full Code Here

import ru.autosome.macroape.calculation.generalized.CompareModelsCountsGiven;
import ru.autosome.macroape.calculation.mono.CompareModels;

public class EvaluateSimilarity {
  public static void main(String[] args){
    PWM firstPWM = new PWMImporter().loadMotif("test_data/pwm/KLF4_f2.pwm");
    PWM secondPWM = new PWMImporter().loadMotif("test_data/pwm/SP1_f1.pwm");
    try {
      Discretizer discretizer = new Discretizer(100.0);

//      CountingPWM firstPWMCounting = new CountingPWM(firstPWM.discrete(discretizer), new WordwiseBackground(), null);
//      CountingPWM secondPWMCounting = new CountingPWM(secondPWM.discrete(discretizer), new WordwiseBackground(), null);
View Full Code Here

  }
 
  // constructs PWM from any source: pwm/pcm/ppm matrix
  @Override
  public PWM createMotif(double matrix[][], String name) {
    PWM pwm;
    switch (dataModel) {
      case PCM:
        pwm = new PCM(matrix, name).to_pwm(background);
        break;
      case PPM:
        pwm = new PPM(matrix, name).to_pwm(background, effectiveCount);
        break;
      case PWM:
        pwm = new PWM(matrix, name);
        break;
      default:
        throw new Error("This code never reached");
    }
    return pwm;
View Full Code Here

     "pvalue: " + info.pvalue + "\n" +
     "number of recognized words: " + info.numberOfRecognizedWords(background, pwmLength) + "\n------------\n");
  }

  public static void main(String[] args) {
    PWM pwm = new PWMImporter().loadMotif("test_data/pwm/KLF4_f2.pwm");
    BackgroundModel background = new WordwiseBackground();
    Discretizer discretizer = new Discretizer(10000.0);
    Integer max_hash_size = null;
    double threshold = 3;
    double[] thresholds = {3,5,7};

    FindPvalueAPE calculator = new FindPvalueAPE<PWM, BackgroundModel>(pwm, background, discretizer, max_hash_size);

      // Single threshold
    {
      CanFindPvalue.PvalueInfo info = null;
      try {
        info = calculator.pvalueByThreshold(threshold);
      } catch (HashOverflowException e) {
        e.printStackTrace();
      }
      print_result(info, background, pwm.length());
    }

      // Multiple thresholds
    {
      CanFindPvalue.PvalueInfo[] infos = new CanFindPvalue.PvalueInfo[0];
      try {
        infos = calculator.pvaluesByThresholds(thresholds);
      } catch (HashOverflowException e) {
        e.printStackTrace();
      }
      for (CanFindPvalue.PvalueInfo info : infos) {
        print_result(info, background, pwm.length());
      }
    }

    // api integration
    double[][] matrix_cAVNCT = { {1.0, 2.0, 1.0, 1.0},
                          {10.5, -3.0, 0.0, 0.0},
                          {5.0, 5.0, 5.0, -10.0},
                          {0.0, 0.0, 0.0, 0.0},
                          {-1.0, 10.5, -1.0, 0.0},
                          {0.0, 0.0, 0.0, 2.0}};
    PWM pwm_manual_constructed = new PWM(matrix_cAVNCT, "PWM for cAVNCt consensus sequence");
    double[] thresholds_2 = {15,16,17};
    ru.autosome.ape.api.FindPvalueAPE.Parameters parameters =
     new ru.autosome.ape.api.FindPvalueAPE.Parameters(pwm_manual_constructed,
                                                      thresholds_2,
                                                      discretizer, background, max_hash_size);
    ru.autosome.ape.api.FindPvalueAPE bioumlCalculator = new ru.autosome.ape.api.FindPvalueAPE(parameters);
    CanFindPvalue.PvalueInfo[] infosBiouml = bioumlCalculator.call();
    for (CanFindPvalue.PvalueInfo bioumlInfo : infosBiouml) {
      print_result(bioumlInfo, background, pwm_manual_constructed.length());
    }
  }
View Full Code Here

                         "actual pvalue: " + info.real_pvalue + "\n" +
                         "number of recognized words: " + info.numberOfRecognizedWords(background, pwmLength) + "\n------------\n");
  }

  public static void main(String[] args) {
    PWM pwm = new PWMImporter().loadMotif("test_data/pwm/KLF4_f2.pwm");
    BackgroundModel background = new WordwiseBackground();
    Discretizer discretizer = new Discretizer(10000.0);
    BoundaryType pvalue_boundary = BoundaryType.LOWER;
    Integer max_hash_size = null;
    double pvalue = 0.0005;
    double[] pvalues = {0.0001, 0.0005, 0.001};

    CanFindThreshold calculator = new FindThresholdAPE<PWM, BackgroundModel>(pwm, background, discretizer, max_hash_size);

    // Single threshold
    {
      CanFindThreshold.ThresholdInfo info = null;
      try {
        info = calculator.thresholdByPvalue(pvalue, pvalue_boundary);
      } catch (HashOverflowException e) {
        e.printStackTrace();
      }
      print_result(info, background, pwm.length());
    }
    // Multiple thresholds
    {
      CanFindThreshold.ThresholdInfo[] infos = new CanFindThreshold.ThresholdInfo[0];
      try {
        infos = calculator.thresholdsByPvalues(pvalues, pvalue_boundary);
      } catch (HashOverflowException e) {
        e.printStackTrace();
      }
      for (CanFindThreshold.ThresholdInfo info : infos) {
        print_result(info, background, pwm.length());
      }
    }
    // api integration
    ru.autosome.ape.api.FindThresholdAPE.Parameters parameters =
     new ru.autosome.ape.api.FindThresholdAPE.Parameters(pwm,
                                                              pvalues,
                                                              background,
                                                              discretizer,pvalue_boundary, max_hash_size);
    ru.autosome.ape.api.FindThresholdAPE bioumlCalculator = new ru.autosome.ape.api.FindThresholdAPE(parameters);
    CanFindThreshold.ThresholdInfo[] infosBiouml = bioumlCalculator.call();
    for (CanFindThreshold.ThresholdInfo bioumlInfo : infosBiouml) {
      print_result(bioumlInfo, background, pwm.length());
    }
  }
View Full Code Here

      e.printStackTrace();
    }
  }

  public static void main(String[] args) {
    PWM pwm = new PWMImporter().loadMotif("test_data/pwm/KLF4_f2.pwm");

    Discretizer discretizer = new Discretizer(10000.0);
    Integer max_hash_size = null;
    double threshold = 7;
//    double[] thresholds = {3,5,7};

    Sequence word = new Sequence("ACAGTGACAA");
    DiPWM dipwm = DiPWM.fromPWM(pwm); // A way to transform mono-nucleotide to di matrix

    System.out.println(pwm.score(word));
    System.out.println(dipwm.score(word));

    //DiPWM dipwm_2 = new DiPWMImporter().loadMotif("test_data/dipwm/AP2A.di"));

    run_mono_and_di(pwm, new WordwiseBackground(), discretizer, max_hash_size, threshold);
View Full Code Here

TOP

Related Classes of ru.autosome.commons.motifModel.mono.PWM

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.