Giter VIP home page Giter VIP logo

alphapart's People

Contributors

prof-thiagooliveira avatar

Watchers

 avatar  avatar  avatar

alphapart's Issues

AlphaPart stops/aborts when data input belongs to the tbl_df class

Describe the bug
AlphaPart stops/aborts when data input belongs to the tbl_df class. Any data manipulated by using tidyverse collection of packages can't be read by the AlphaPart.

Screenshots
R Session aborted - R encountered a fatal error and was terminated.

Desktop (please complete the following information):

  • OS: Ubuntu 21.10
  • AlphaPart version 0.9.1 (it happens in any version)

Rcpp code improvement

Is your feature request related to a problem? Please describe.
A possible improvement to the Rcpp functions.

Describe the solution you'd like

#include "AlphaPartDrop.h"
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
List AlphaPartDrop(double c1, double c2, int nI, int nP, int nT, NumericMatrix ped, IntegerVector P, IntegerVector Px) {

  // --- Outputs ---
  NumericMatrix pa(nI+1, nT);    // parent average
  NumericMatrix w(nI+1, nT);     // Mendelian sampling
  NumericMatrix xa(nI+1, nP*nT); // Parts

  // --- Compute ---
  for(int i = 1; i < nI+1; i++) {
    for(int t = 0; t < nT; t++) {
      // Parent average (PA)
      pa(i, t) = c1 * ped(i-1, 3+t) + c2 * ped(i-1, 3+nT+t);
    
      // Mendelian sampling (MS)
      w(i, t) = ped(i-1, 3+t) - pa(i, t);
    
      // Parts

      // ... for the MS part
      int j = Px[t] + P[i];
      xa(i, j) = w(i, t);

      // ... for the PA parts
      for(int p = 0; p < nP; p++) {
        j = Px[t] + p;
        xa(i, j) += c1 * xa(ped(i-1, 3), j) + c2 * xa(ped(i-1, 3+nT), j);
      }
    }
  }
  
  // --- Return ---
  return List::create(Named("pa") = pa, Named("w") = w, Named("xa") = xa);
}

Changes:

Same for AlphaPartDropGroup:

#include "AlphaPartDropGroup.h"
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
NumericMatrix AlphaPartDropGroup(double c1, double c2, int nI, int nP, int nT, int nG,
                                 NumericMatrix ped, IntegerVector P, IntegerVector Px, IntegerVector g) {
  
  // --- Outputs ---
  
  NumericMatrix pa(nI+1, nT);    // parent average
  NumericMatrix w(nI+1, nT);     // Mendelian sampling
  NumericMatrix xa(nI+1, nP*nT); // Parts
  NumericMatrix xg(nG+1, nP*nT); // Parts for groups
  
  // --- Compute ---
  
  for (int i = 1; i < nI+1; i++) {
    for (int t = 0; t < nT; t++) {
      // Parent average (PA)
      pa(i, t) = c1 * ped(ped(i, 1), 3+t) + c2 * ped(ped(i, 2), 3+t);
    
      // Mendelian sampling (MS)
      w(i, t) = ped(i, 3+t) - pa(i, t);
    
      // Parts
      int j = Px[t] + P[i];
      
      // ... for the MS part
      xa(i, j) = w(i, t);
      
      // ... for the PA parts
      for (int p = 0; p < nP; p++) {
        j = Px[t] + p;
        xa(i, j) += c1 * xa(ped(i, 1), j) + c2 * xa(ped(i, 2), j);
        
        // Accumulate parts by group
        xg(g(i), j) += xa(i, j);
      }
    }
  }
  
  // --- Return ---
  
  return xg;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.