Skip to content

Instantly share code, notes, and snippets.

View wckdouglas's full-sized avatar

Douglas Wu wckdouglas

View GitHub Profile
#include <zlib.h>
#include <stdio.h>
#include <string.h>
#include "kseq.h"
#include "khash.h"
KSEQ_INIT(gzFile, gzread);
KHASH_SET_INIT_STR(s)
#define BUF_SIZE 2048
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector removeNA(NumericVector a)
{
int vectorLength = a.size();
NumericVector result(vectorLength);
for (int i = 0; i < vectorLength ; i++)
@wckdouglas
wckdouglas / sort.cpp
Last active August 29, 2015 14:21
bubble sort
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector bubbleSort(NumericVector a){
//sorting a numeric vector in to a ascending list//
int j, flag, vectorSize = a.size();
double tempVal;
NumericVector sortedVector(clone(a));
NumericVector finalIndex(vectorSize);
@wckdouglas
wckdouglas / FDRcontrol.cpp
Last active August 29, 2015 14:21
A cpp version of Benjamini & Hochberg method for FDR control
#include <Rcpp.h>
#include <stdlib.h>
using namespace Rcpp;
using namespace std;
// define pairs
typedef pair<double,int> pairType;
// define method for sorting
@wckdouglas
wckdouglas / string_split.cpp
Last active August 29, 2015 14:21
splitting character vector
#include <Rcpp.h>
#include <sstream>
#include <string>
#include <vector>
using namespace Rcpp;
using namespace std;
typedef vector<string> stringList;
typedef vector<int> numList;
{% include comments.html %}
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = 'douglaswu';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
#include <glob.h>
#include <iostream>
#include <fstream>
#include <gzstream.h>
#include <sstream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <libgen.h>
#include <string.h>
#include <Rcpp.h>
using namespace Rcpp;
double getProb(double p, int success, int fail){
double e = success * log(p) + fail * log(1-p);
return e;
}
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <map>