Skip to content

Commit

Permalink
version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdanielnd authored and gaborcsardi committed Aug 8, 2015
1 parent 5678fab commit 181acc8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: slfm
Type: Package
Title: Tools for Fitting Sparse Latent Factor Model
Version: 0.2.0
Version: 0.2.1
Author: Joao Duarte and Vinicius Mayrink
Maintainer: Joao Duarte <jdanielnd@gmail.com>
Description: Set of tools to find coherent patterns in microarray data
Expand All @@ -21,6 +21,6 @@ Imports: Rcpp (>= 0.11.0), coda, lattice
LinkingTo: Rcpp, RcppArmadillo
License: GPL-2
NeedsCompilation: yes
Packaged: 2015-07-29 00:03:10 UTC; jdanielnd
Packaged: 2015-08-08 15:03:06 UTC; jdanielnd
Repository: CRAN
Date/Publication: 2015-07-29 06:21:43
Date/Publication: 2015-08-08 17:41:43
10 changes: 5 additions & 5 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
09c6391016c6b753e69a7534e10b8727 *DESCRIPTION
c63be246b93827f2e4574d3231acab25 *DESCRIPTION
87b17ef5c347ec4ca6d1641066700c30 *NAMESPACE
bd3d6f4d64ee1b4f4804ad427a2745d2 *NEWS
c16341d14e28876570e5c0f0a6b1ff87 *NEWS
3e11a37d28ca0244100992886a82d3d5 *R/RcppExports.R
c2bee89222b5b1d2f8a3b4ee0d5c59a6 *R/class_interval.r
32e909834a9fc4e509216e033d45c8f6 *R/class_interval.r
baabf72d4bc884b4c1a64efa0ab6929f *R/plot_matrix.r
87f7eeceee7273541541ba5c589103ec *R/process_matrix.r
43023f17cf4534c205f467c51594dff3 *R/slfm-package.r
75aa158541ee3aed3c5084841a138dbc *R/slfm.r
ccb2e56a2738d8fd42b70f0bf0adc061 *R/slfm_list.r
ccef8b309606ef4d17db2c21c47019ea *R/slfm.r
58005212f9aba9f2f545e0f1a0630f3e *R/slfm_list.r
540f05f21a09f459cc33f9d244ac919d *man/plot_matrix.Rd
59958c4ef88f62f062a57ede17dd64c7 *man/process_matrix.Rd
50feb9e98613c1d6ee4e2ca0aa62a5fd *man/slfm-package.Rd
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
slfm 0.2.1
===========

* adding % significant column to slfm_list output

* using S/N/I notation to slfm output

slfm 0.2.0
===========

Expand Down
12 changes: 6 additions & 6 deletions R/class_interval.r
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class_interval_uni <- function(x, cv = 0.5) {
if(x[2] < cv) {
clas <- "A"
clas <- "N"
} else if(x[1] > cv) {
clas <- "P"
clas <- "S"
} else {
clas <- "M"
clas <- "I"
}
return(clas)
}
Expand All @@ -16,9 +16,9 @@ class_interval <- function(x) {
format_classification <- function(x) {
x <- as.factor(x)
lvls <- levels(x)
lvls[lvls == "P"] <- "Present"
lvls[lvls == "M"] <- "Marginal"
lvls[lvls == "A"] <- "Absent"
lvls[lvls == "S"] <- "S"
lvls[lvls == "I"] <- "I"
lvls[lvls == "N"] <- "N"
levels(x) <- lvls
x
}
Expand Down
4 changes: 2 additions & 2 deletions R/slfm.r
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ slfm <- function(
x = x,
alpha = table_alpha,
lambda = table_lambda,
sigma = table_sigma,
sigma2 = table_sigma,
alpha_matrix = alpha_matrix,
lambda_matrix = lambda_matrix,
sigma_matrix = sigma_matrix,
sigma2_matrix = sigma_matrix,
q_star = q_star_matrix,
z_matrix = z_matrix,
classification = alpha_clas)
Expand Down
13 changes: 9 additions & 4 deletions R/slfm_list.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ slfm_list <- function(
files_list <- list.files(path, recursive = recursive, full.names = T)

message("* |Press Ctrl + C to cancel...")
pb <- txtProgressBar(0, length(files_list), style = 3, title = "BLA")
pb <- txtProgressBar(0, length(files_list), style = 3, title = "")

MATRIX_CLASSIFICATION <- c("Present", "Marginal", "Absent")
names(MATRIX_CLASSIFICATION) <- c("S", "I", "N")

results_list <- list()
for(i in 1:length(files_list)) {
file_name <- files_list[i]
mat <- read.table(file_name)

res <- slfm(mat, a, b, gamma_a, gamma_b, omega_0, omega_1, sample, burnin, lag, degenerate)
final_clas <- names(which.max(table(res$classification)))
results_list[[i]] <- c(name=basename(tools::file_path_sans_ext(file_name)), clas=final_clas)
clas_table <- table(res$classification)
final_clas <- MATRIX_CLASSIFICATION[names(which.max(clas_table))]
freq <- format(round(clas_table["S"]/sum(clas_table), 4), nsmall = 4)
results_list[[i]] <- c(name = basename(tools::file_path_sans_ext(file_name)), clas = final_clas, frequency = freq)

setTxtProgressBar(pb, i)
}
close(pb)
ret <- as.data.frame(do.call(rbind, results_list))
names(ret) <- c("File", "Classification")
names(ret) <- c("File", "Classification", "Significant %")
ret
}

0 comments on commit 181acc8

Please sign in to comment.