This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('pheatmap') | |
##~~~~~~~~~~~~~~~~~~simulating data~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
rn <- 100 | |
cn <- 12 | |
testdat <- matrix(rnorm(rn * cn), rn, cn) | |
testdat[1 : (rn/2), seq(1, cn, 2)] <- testdat[1 : (rn/2), seq(1, cn, 2)] + 5 | |
testdat[(rn/2 + 1) : rn, seq(2, cn, 2)] <- testdat[(rn/2 + 1) : rn, seq(2, cn, 2)] + 7 | |
testdat <- apply(testdat, 1:2, function(x) ifelse(x < 0, 0, x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RcppArmadillo.h> | |
#include <RcppParallel.h> | |
#include <tthread/tinythread.h> | |
#include <algorithm> | |
#include <vector> | |
using namespace Rcpp; | |
using namespace RcppParallel; | |
using namespace arma; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RcppArmadillo.h> | |
#include <RcppParallel.h> | |
#include <algorithm> | |
#include <vector> | |
using namespace Rcpp; | |
using namespace RcppParallel; | |
using namespace arma; | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <RcppArmadillo.h> | |
#include <RcppParallel.h> | |
#include <algorithm> | |
#include <cmath> | |
using namespace Rcpp; | |
using namespace RcppParallel; | |
using namespace arma; | |
// [[Rcpp::depends(RcppArmadillo, RcppParallel)]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('microbenchmark') | |
library('Rcpp') | |
library('RcppParallel') | |
library('foreach') | |
library('parallel') | |
library('doParallel') | |
library('iterators') | |
sourceCpp('testrcpp.cpp') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## set working path | |
setwd('/home/Yulong/RESEARCH/QAPTest/') | |
## to symmetric matrix | |
SymMat <- function(mat) { | |
## example | |
## tmp1 <- matrix(c(1, '-', '-', 2, 4, '-', 3, 5, 6), ncol = 3, byrow = TRUE) | |
mat <- apply(mat, 1:2, as.character) | |
mat <- ifelse(mat == '-', 0, mat) | |
mat <- apply(mat, 1:2, as.numeric) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <limits> | |
using namespace std; | |
int main() { | |
int a = numeric_limits<int>::min(); | |
int b = numeric_limits<int>::max(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <limits.h> | |
#include <float.h> | |
int main() { | |
int a = INT_MIN; | |
int b = INT_MAX; | |
double c = DBL_MIN; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
double sum = 0.0; | |
double step = 0.01; | |
double each = 0.01; | |
for (int i = 0; i < 100; ++i) { | |
sum += step; | |
step += each; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###Download gff/fna/ptt/rnt annotation files of a prokaryotic genome #### | |
## Escherichia coli str. K-12 substr. MG1655 (E. coli) | |
## KEGG ID is 'eco' (http://www.genome.jp/kegg-bin/show_organism?org=eco) | |
## NCBI assembly ID is 'GCF_000005845.2' (https://www.ncbi.nlm.nih.gov/assembly/GCF_000005845.2) | |
library('ProGenome') ## version >= 0.06 | |
library('magrittr') |
NewerOlder