Found 128571 results in 20446 files, showing top 50 files (show more).
QUBIC:src/matrix.h: [ ]
7: template<typename T> class Matrix {
12:   Matrix(std::size_t reserved_count) {
2: #define MATRIX_H
1: #ifndef MATRIX_H
LymphoSeq:R/differentialAbundance.R: [ ]
66:         matrix <- matrix(c(in.x, in.y, not.x, not.y), nrow = 2)
67:         fisher <- stats::fisher.test(matrix, workspace = 2e6)
shinyMethyl:R/server.R: [ ]
97:             matrix <- apply(quantiles, 2, function(x){
101:             matrix.x <- matrix[1:512,]
102:             matrix.y <- matrix[513:(2*512),]
223:                 density.matrix <- returnDensityMatrix()
224:                 x.matrix <- density.matrix[[1]]
225:                 y.matrix <- density.matrix[[2]]
87: 	returnDensityMatrix <- reactive({
107: 	returnDensityMatrixNorm <- reactive({
103:             return(list(matrix.x = matrix.x, matrix.y = matrix.y))
121:             matrix <- apply(quantiles, 2, function(x){
125:             matrix.x <- matrix[1:512,]
126:             matrix.y <- matrix[513:(2*512),]
127:             return(list(matrix.x = matrix.x, matrix.y = matrix.y))	
226:                 x.matrix <- ((x.matrix - mouse.x)/range.x)^2
227:                 y.matrix <- ((y.matrix - mouse.y)/range.y)^2
228:                 clickedIndex <- arrayInd(which.min(x.matrix+y.matrix),
229:                                          c(512,ncol(x.matrix)))[2]
266:                 density.matrix <- returnDensityMatrixNorm()
267:                 x.matrix <- density.matrix[[1]]
268:                 y.matrix <- density.matrix[[2]]
269:                 x.matrix <- ((x.matrix - mouse.x)/range.x)^2
270:                 y.matrix <- ((y.matrix - mouse.y)/range.y)^2
271:                 clickedIndex <- arrayInd(which.min(x.matrix+y.matrix),
272:                                          c(512,ncol(x.matrix)))[2]
359:             densitiesPlot(matrix.x = returnDensityMatrix()[[1]],
360:                           matrix.y = returnDensityMatrix()[[2]],
372:                                 matrix.x = returnDensityMatrix()[[1]],
373:                                 matrix.y = returnDensityMatrix()[[2]],
426: 		densitiesPlot(matrix.x = returnDensityMatrixNorm()[[1]],
427:                               matrix.y = returnDensityMatrixNorm()[[2]],
439:                                     matrix.x = returnDensityMatrixNorm()[[1]],
440:                                     matrix.y = returnDensityMatrixNorm()[[2]],
616:             matrix <- apply(betaQuantiles[[index]], 2, function(x){
620:             matrix.x <- matrix[1:512,]
621:             matrix.y <- matrix[513:(2*512),]
629:             densitiesPlot(matrix.x = matrix.x,
630:                           matrix.y = matrix.y,
BADER:src/meth.h: [ ]
6: } Matrix;
2: typedef struct MatrixStructure {
20:     Matrix kA;
21:     Matrix kB;
24:     Matrix lambdaA;
26:     Matrix lambdaB;
44: double columnMean ( Matrix &A, int column )
95: void mult ( Vector &a, Matrix &X, Vector &b )
HiCBricks:R/Brick_functions.R: [ ]
2168:     Matrix <- Brick_get_matrix(Brick = Brick, chr1 = chr1, chr2 = chr2,
2255:     Matrix <- Brick_get_vector_values(Brick = Brick, chr1=chr1, chr2=chr2,
554:     Matrix_info <- return_configuration_matrix_info(Brick)
776:     Matrix.list.df <- do.call(rbind,chr1.list)
1322: Brick_load_matrix = function(Brick = NA, chr1 = NA, chr2 = NA, resolution = NA,
1613:     Matrix.list <- Brick_list_matrices(Brick = Brick, chr1 = chr1, 
1657:     Matrix.list <- Brick_list_matrices(Brick = Brick, chr1 = chr1, chr2 = chr2,
1713:     Matrix.list <- Brick_list_matrices(Brick = Brick, chr1 = chr1, chr2 = chr2,
1803:     Matrix.list <- Brick_list_matrices(Brick = Brick, chr1 = chr1, chr2 = chr2,
1898:     Matrix.list <- Brick_list_matrices(Brick = Brick, chr1 = chr1, chr2 = chr2,
2228: Brick_get_matrix = function(Brick, chr1, chr2, x_coords,
2574: Brick_get_entire_matrix = function(Brick, chr1, chr2, resolution){
2592:     entire_matrix <- dataset_handle[]
2848:     a_matrix <- .remove_nas(Brick_get_entire_matrix(Brick = Brick, 
2850:     normalised_matrix <- .normalize_by_distance_values(a_matrix)
2851:     correlation_matrix <- cor(normalised_matrix)
206:     Configuration_matrix_list <- list()
1419: Brick_load_cis_matrix_till_distance = function(Brick = NA, chr = NA, 
1607: Brick_matrix_isdone = function(Brick, chr1, chr2, resolution = NA){
1651: Brick_matrix_issparse = function(Brick, chr1, chr2, resolution = NA){
1703: Brick_matrix_maxdist = function(Brick, chr1, chr2, resolution = NA){
1758: Brick_matrix_exists = function(Brick, chr1, chr2, resolution = NA){
1797: Brick_matrix_minmax = function(Brick, chr1, chr2, resolution = NA){
1843: Brick_matrix_dimensions = function(Brick, chr1, chr2, resolution = NA){
1892: Brick_matrix_filename = function(Brick, chr1, chr2, resolution = NA){
2124: Brick_get_matrix_within_coords = function(Brick, x_coords,
2647: Brick_get_matrix_mcols = function(Brick, chr1, chr2, resolution, 
2706: Brick_list_matrix_mcols = function(){
8: #' table associated to the Hi-C experiment, creates a 2D matrix
21: #' contains 250 entries in the binning table, the _cis_ Hi-C data matrix for
24: #' matrices for chr1,chr2 will be a matrix with dimension 250 rows and
60: #' set to matrix dimensions/100.
95: #'                \item Min - min value of Hi-C matrix
96: #'                \item Max - max value of Hi-C matrix
97: #'                \item sparsity - specifies if this is a sparse matrix
99: #'                \item Done - specifies if a matrix has been loaded
101: #'            \item matrix - \strong{dataset} - contains the matrix
235:         Configuration_matrix_list <- return_configuration_matrix_info(
267:             Configuration_matrix_list[[paste(chrom1, chrom2, 
281:         Configuration_matrix_list, 
527: #' for that chromosome in a Hi-C matrix.
555:     current_resolution <- vapply(Matrix_info, function(a_list){
561:     chrom1_binned_length <- vapply(Matrix_info[current_resolution], 
565:     chrom1s <- vapply(Matrix_info[current_resolution], 
569:     chrom1_max_sizes <- vapply(Matrix_info[current_resolution], 
720: #' List the matrix pairs present in the Brick store.
727: #' @inheritParams Brick_load_matrix
733: #' minimum and maximum values in the matrix, done is a logical value
734: #' specifying if a matrix has been loaded and sparsity specifies if a matrix
735: #' is defined as a sparse matrix.
777:     rownames(Matrix.list.df) <- NULL
778:     return(Matrix.list.df)
1263: #' Load a NxM dimensional matrix into the Brick store.
1269: #' the rows of the matrix
1273: #' the columns of the matrix
1275: #' @param matrix_file \strong{Required}.
1277: #' matrix into the Brick store.
1280: #' The delimiter of the matrix file.
1283: #' If a matrix was loaded before, it will not be replaced. Use remove_prior to
1284: #' override and replace the existing matrix.
1290: #' If true, designates the matrix as being a sparse matrix, and computes the
1306: #' out_dir <- file.path(tempdir(), "matrix_load_test")
1314: #' Matrix_file <- system.file(file.path("extdata", 
1318: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1319: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1323:     matrix_file = NA, delim = " ", remove_prior = FALSE, num_rows = 2000, 
1328:         resolution = resolution, matrix_file = matrix_file, 
1348:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2,
1352:     if(Brick_matrix_isdone(Brick = Brick, chr1 = chr1,
1354:         stop("A matrix was preloaded before. ",
1367:         Matrix.file = matrix_file, delim = delim, Group.path = Group.path, 
1375: #' Load a NxN dimensional sub-distance \emph{cis} matrix into
1380: #' @inheritParams Brick_load_matrix
1384: #' the rows and cols of the matrix
1388: #' it does not make sense to load the entire matrix into the data structure, as
1389: #' after a certain distance, the matrix will become extremely sparse. This
1403: #' out_dir <- file.path(tempdir(), "matrix_load_dist_test")
1411: #' Matrix_file <- system.file(file.path("extdata", 
1415: #' Brick_load_cis_matrix_till_distance(Brick = My_BrickContainer, 
1416: #' chr = "chr2L", resolution = 100000, matrix_file = Matrix_file, 
1420:     resolution = NA, matrix_file, delim = " ", distance, remove_prior = FALSE,
1425:         matrix_file = matrix_file, delim = delim, distance = distance, 
1443:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr,
1447:     if(Brick_matrix_isdone(Brick = Brick, chr1 = chr,
1449:         stop("A matrix was preloaded before. Use remove_prior = TRUE to ",
1461:     RetVar <- ._Process_matrix_by_distance(Brick = Brick_filepath,
1462:         Matrix.file = matrix_file, delim = delim, Group.path = Group.path,
1470: #' Load a NxN dimensional matrix into the Brick store from an mcool file.
1472: #' Read an mcool contact matrix coming out of 4D nucleome projects into a
1477: #' @inheritParams Brick_load_matrix
1489: #' @param matrix_chunk \strong{Optional}. Default 2000.
1490: #' The nxn matrix square to fill per iteration in a mcool file.
1493: #' cooler_read_limit sets the upper limit for the number of records per matrix
1495: #' matrix_chunk value will be re-evaluated dynamically.
1521: #' resolution = 50000, matrix_chunk = 2000, remove_prior = TRUE,
1527: #' @seealso \code{\link{Create_many_Bricks_from_mcool}} to create matrix from 
1533:     matrix_chunk = 2000, cooler_read_limit = 10000000, remove_prior = FALSE,
1569:         resolution = resolution, matrix_chunk = matrix_chunk, 
1575: #' Check if a matrix has been loaded for a chromosome pair.
1579: #' @inheritParams Brick_load_matrix
1581: #' @return Returns a logical vector of length 1, specifying if a matrix has
1588: #' out_dir <- file.path(tempdir(), "matrix_isdone_test")
1596: #' Matrix_file <- system.file(file.path("extdata", 
1600: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1601: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1604: #' Brick_matrix_isdone(Brick = My_BrickContainer, chr1 = "chr2L", 
1609:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2,
1615:     return(Matrix.list[Matrix.list$chr1 == chr1 &
1616:         Matrix.list$chr2 == chr2, "done"])
1619: #' Check if a matrix for a chromosome pair is sparse.
1623: #' @inheritParams Brick_load_matrix
1625: #' @return Returns a logical vector of length 1, specifying if a matrix was
1626: #' loaded as a sparse matrix.
1632: #' out_dir <- file.path(tempdir(), "matrix_issparse_test")
1640: #' Matrix_file <- system.file(file.path("extdata", 
1644: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1645: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1648: #' Brick_matrix_issparse(Brick = My_BrickContainer, chr1 = "chr2L", 
1653:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2,
1659:     return(Matrix.list[Matrix.list$chr1 == chr1 &
1660:         Matrix.list$chr2 == chr2, "sparsity"])
1664: #' Get the maximum loaded distance from the diagonal of any matrix.
1666: #' If values beyond a certain distance were not loaded in the matrix, this
1670: #' `Brick_matrix_maxdist` will return this parameter.
1674: #' @inheritParams Brick_load_matrix
1677: #' distance loaded for that matrix
1684: #' out_dir <- file.path(tempdir(), "matrix_maxdist_test")
1692: #' Matrix_file <- system.file(file.path("extdata", 
1696: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1697: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1700: #' Brick_matrix_maxdist(Brick = My_BrickContainer, chr1 = "chr2L", 
1705:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2,
1709:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2, 
1715:     return((Matrix.list[Matrix.list$chr1 == chr1 &
1716:         Matrix.list$chr2 == chr2, "distance"]))
1722: #' are provided. If a user is in doubt regarding whether a matrix is present or
1729: #' @inheritParams Brick_load_matrix
1731: #' @return Returns a logical vector of length 1, specifying if the matrix
1739: #' out_dir <- file.path(tempdir(), "matrix_exists_test")
1747: #' Matrix_file <- system.file(file.path("extdata", 
1751: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1752: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1755: #' Brick_matrix_exists(Brick = My_BrickContainer, chr1 = "chr2L", 
1765: #' Return the value range of the matrix
1769: #' @inheritParams Brick_load_matrix
1772: #' maximum finite real values in the matrix.
1778: #' out_dir <- file.path(tempdir(), "matrix_minmax_test")
1786: #' Matrix_file <- system.file(file.path("extdata", 
1790: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1791: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1794: #' Brick_matrix_minmax(Brick = My_BrickContainer, chr1 = "chr2L", 
1799:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2, 
1805:     Filter <- Matrix.list$chr1 == chr1 & Matrix.list$chr2 == chr2
1806:     Extent <- c(Matrix.list[Filter, "min"],Matrix.list[Filter, "max"])
1810: #' Return the dimensions of a matrix
1814: #' @inheritParams Brick_load_matrix
1816: #' @return Returns the dimensions of a Hi-C matrix for any given
1824: #' out_dir <- file.path(tempdir(), "matrix_dimension_test")
1832: #' Matrix_file <- system.file(file.path("extdata", 
1836: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1837: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1840: #' Brick_matrix_dimensions(Brick = My_BrickContainer, chr1 = "chr2L", 
1844:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2, 
1853:         dataset.path = Reference.object$hdf.matrix.name,
1859: #' Return the filename of the loaded matrix
1863: #' @inheritParams Brick_load_matrix
1866: #' the currently loaded matrix.
1873: #' out_dir <- file.path(tempdir(), "matrix_filename_test")
1881: #' Matrix_file <- system.file(file.path("extdata", 
1885: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1886: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1889: #' Brick_matrix_filename(Brick = My_BrickContainer, chr1 = "chr2L", 
1894:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2, 
1900:     Filter <- Matrix.list$chr1 == chr1 & Matrix.list$chr2 == chr2
1901:     Extent <- Matrix.list[Filter, "filename"]
1914: #' A string specifying the chromosome for the cis Hi-C matrix from which values
1947: #' Matrix_file <- system.file(file.path("extdata", 
1951: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
1952: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
1966: #' @seealso \code{\link{Brick_get_matrix_within_coords}} to get matrix by
1967: #' using matrix coordinates, \code{\link{Brick_fetch_row_vector}} to get values
1969: #' to get values using matrix coordinates, \code{\link{Brick_get_matrix}} to
1970: #' get matrix by using matrix coordinates.
1979:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr, 
1981:         !Brick_matrix_isdone(Brick = Brick, chr1 = chr, 
1993:     Max.dist <- Brick_matrix_maxdist(Brick = Brick, chr1 = chr, chr2 = chr,
1997:             "this matrix was at a distance of "
2041:             Name = Reference.object$hdf.matrix.name,
2055: #' Return a matrix subset between two regions.
2057: #' `Brick_get_matrix_within_coords` will fetch a matrix subset after
2060: #' This function calls \code{\link{Brick_get_matrix}}.
2075: #' If true, will force the retrieval operation when matrix contains loaded
2080: #' the matrix is returned.
2082: #' @return Returns a matrix of dimension x_coords binned length by y_coords
2090: #' out_dir <- file.path(tempdir(), "get_matrix_coords_test")
2098: #' Matrix_file <- system.file(file.path("extdata", 
2102: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2103: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2106: #' Brick_get_matrix_within_coords(Brick = My_BrickContainer,
2111: #' Brick_get_matrix_within_coords(Brick = My_BrickContainer,
2118: #' @seealso \code{\link{Brick_get_matrix}} to get matrix by using matrix
2122: #' \code{\link{Brick_get_vector_values}} to get values using matrix
2152:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2,
2154:         stop(chr1," ",chr2," matrix is yet to be loaded into the class.")
2171:     return(Matrix)
2174: #' Return a matrix subset.
2176: #' `Brick_get_matrix` will fetch a matrix subset between row values
2182: #' @inheritParams Brick_load_matrix
2191: #' If provided a data transformation with FUN will be applied before the matrix
2194: #' @inheritParams Brick_get_matrix_within_coords
2196: #' @return Returns a matrix of dimension x_coords length by y_coords length.
2203: #' out_dir <- file.path(tempdir(), "get_matrix_test")
2211: #' Matrix_file <- system.file(file.path("extdata", 
2215: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2216: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2219: #' Brick_get_matrix(Brick = My_BrickContainer, chr1 = "chr2L", chr2 = "chr2L",
2222: #' @seealso \code{\link{Brick_get_matrix_within_coords}} to get matrix by using
2223: #' matrix genomic coordinates, \code{\link{Brick_get_values_by_distance}} to
2227: #' matrix coordinates.
2243:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2, 
2245:         stop(chr1,chr2," matrix is yet to be loaded into the class.\n")
2258:         return(Matrix)             
2260:         return(FUN(Matrix))
2266: #' `Brick_fetch_row_vector` will fetch any given rows from a matrix. If
2273: #' @inheritParams Brick_load_matrix
2293: #' @inheritParams Brick_get_matrix_within_coords
2300: #' If provided a data transformation with FUN will be applied before the matrix
2320: #' Matrix_file <- system.file(file.path("extdata", 
2324: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2325: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2334: #' @seealso \code{\link{Brick_get_matrix_within_coords}} to get matrix by
2335: #' using matrix genomic coordinates, \code{\link{Brick_get_values_by_distance}}
2338: #' subset them, \code{\link{Brick_get_matrix}} to get matrix by using
2339: #' matrix coordinates.
2354:     max.dist <- Brick_matrix_maxdist(Brick = Brick, chr1 = chr1, chr2 = chr2, 
2359:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2,
2361:         stop(chr1,chr2," matrix is yet to be loaded.")
2437: #' other matrix retrieval functions.
2441: #' @inheritParams Brick_load_matrix
2457: #' @inheritParams Brick_get_matrix_within_coords
2460: #' returns a matrix of dimension xaxis length by yaxis length.
2477: #' Matrix_file <- system.file(file.path("extdata", 
2481: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2482: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2503:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2,
2505:         stop(chr1,chr2," matrix is yet to be loaded.")
2513:     Max.dist <- Brick_matrix_maxdist(Brick = Brick, chr1 = chr1, chr2 = chr2, 
2518:             "this matrix was at a distance of ",
2527:         Brick = Brick_filepath, Name = Reference.object$hdf.matrix.name, 
2536: #' Return an entire matrix for provided chromosome pair for a resolution.
2538: #' `Brick_get_entire_matrix` will return the entire matrix for the entire 
2544: #' @inheritParams Brick_load_matrix
2546: #' @return Returns an object of class matrix with dimensions corresponding to
2563: #' Matrix_file <- system.file(file.path("extdata", 
2567: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2568: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2571: #' Entire_matrix <- Brick_get_entire_matrix(Brick = My_BrickContainer, 
2581:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2,
2583:         stop(chr1,chr2," matrix is yet to be loaded.")
2590:         Brick = Brick_filepath, Name = Reference_object$hdf.matrix.name, 
2594:     return(entire_matrix)
2597: #' Get the matrix metadata columns in the Brick store.
2599: #' `Brick_get_matrix_mcols` will get the specified matrix metadata column for
2600: #' a chr1 vs chr2 Hi-C data matrix. Here, chr1 represents the rows and chr2
2601: #' represents the columns of the matrix. For cis Hi-C matrices, where 
2615: #' @inheritParams Brick_load_matrix
2618: #' A character vector of length 1 specifying the matrix metric to retrieve
2620: #' @return Returns a 1xN dimensional vector containing the specified matrix
2628: #' out_dir <- file.path(tempdir(), "get_matrix_mcols_test")
2636: #' Matrix_file <- system.file(file.path("extdata", 
2640: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2641: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2644: #' Brick_get_matrix_mcols(Brick = My_BrickContainer, chr1 = "chr2L", 
2652:     Meta.cols <- Reference.object$hdf.matrix.meta.cols()
2657:     if(!Brick_matrix_exists(Brick = Brick, chr1 = chr1, chr2 = chr2, 
2659:         stop("Matrix for this chromsome pair does not exist.\n")  
2661:     if(!Brick_matrix_isdone(Brick = Brick, chr1 = chr1, chr2 = chr2,
2663:         stop("Matrix for this chromsome pair is yet to be loaded.\n")  
2668:     if(!Brick_matrix_issparse(Brick = Brick, chr1 = chr1, chr2 = chr2,
2670:         stop("This matrix is not a sparse matrix.",
2685: #' List the matrix metadata columns in the Brick store.
2687: #' `Brick_get_matrix_mcols` will list the names of all matrix metadata 
2690: #' @return Returns a vector containing the names of all matrix metadata columns
2697: #' out_dir <- file.path(tempdir(), "list_matrix_mcols_test")
2705: #' Brick_list_matrix_mcols()
2708:     Meta.cols <- Reference.object$hdf.matrix.meta.cols()
2714: #' upper triangle sparse matrix
2719: #' objects as a upper triangle sparse matrix (col > row) containing 
2746: #' Matrix_file <- system.file(file.path("extdata", 
2750: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2751: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2833: #' Matrix_file <- system.file(file.path("extdata", 
2837: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2838: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2852:     correlation_matrix <- .remove_nas(correlation_matrix)
2856:     pca_list <- prcomp(correlation_matrix)
2868: #' @inheritParams Brick_load_matrix
2873: #' sparse matrix
2875: #' @param matrix_chunk \strong{Optional}. Default 2000.
2876: #' The nxn matrix square to fill per iteration.
2900: #' Matrix_file <- system.file(file.path("extdata", 
2904: #' Brick_load_matrix(Brick = My_BrickContainer, chr1 = "chr2L", 
2905: #' chr2 = "chr2L", matrix_file = Matrix_file, delim = " ", 
2918:     resolution = NULL, batch_size = 1000000, matrix_chunk = 2000,
2930:         delim = delim, resolution = resolution, matrix_chunk = matrix_chunk, 
173:     Reference.object <- GenomicMatrix$new()
330:     Reference.object <- GenomicMatrix$new()
426:     Reference.object <- GenomicMatrix$new()
468:     Reference.object <- GenomicMatrix$new()
549:     Reference.object <- GenomicMatrix$new()
617:     Reference.object <- GenomicMatrix$new()
691:     Reference.object <- GenomicMatrix$new()
756:     Reference.object <- GenomicMatrix$new()
810:     Reference.object <- GenomicMatrix$new()
892:     Reference.object <- GenomicMatrix$new()
953:     Reference.object <- GenomicMatrix$new()
1086:     Reference.object <- GenomicMatrix$new()
1325:     Reference.object <- GenomicMatrix$new()
1366:     RetVar <- ._ProcessMatrix_(Brick = Brick_filepath, 
1423:     Reference.object <- GenomicMatrix$new()
1535:     Reference.object <- GenomicMatrix$new()
1608:     Reference.object <- GenomicMatrix$new()
1652:     Reference.object <- GenomicMatrix$new()
1704:     Reference.object <- GenomicMatrix$new()
1798:     Reference.object <- GenomicMatrix$new()
1848:     Reference.object <- GenomicMatrix$new()
1893:     Reference.object <- GenomicMatrix$new()
1977:     Reference.object <- GenomicMatrix$new()
2494:     Reference.object <- GenomicMatrix$new()
2575:     Reference_object <- GenomicMatrix$new()
2651:     Reference.object <- GenomicMatrix$new()
2707:     Reference.object <- GenomicMatrix$new()
2760:     Reference.object <- GenomicMatrix$new()
2920:     Reference.object <- GenomicMatrix$new()
chromPlot:R/chromplot-Internal.R: [ ]
898:     matrix <- t(sapply(data, unlist)) #list to matrix
325:                     plot.lodclust(as.matrix(track[,c("Start", "End")]),
396:     intervals <- as.matrix(intervals)
445:     intmat  <- matrix(intmat, ncol=2)
517:     if(is.data.frame(x) | is.matrix(x)) {
899:     aux    <-matrix[, c(2:5)]
CellaRepertorium:src/cdhit-common.h: [ ]
183: 		int matrix[MAX_AA][MAX_AA];
173: typedef Vector<VectorInt> MatrixInt;
176: typedef Vector<VectorInt64> MatrixInt64;
179: class ScoreMatrix { //Matrix
197: typedef Vector<VectorIntX> MatrixIntX;
189: 		void set_matrix(int *mat1);
186: 		ScoreMatrix();
193: }; // END class ScoreMatrix
476: 	MatrixInt64  score_mat;
477: 	MatrixInt    back_mat;
531: extern ScoreMatrix  mat;
606: int local_band_align( char query[], char ref[], int qlen, int rlen, ScoreMatrix &mat,
Director:inst/www/js/d3.v3.js: [ ]
6188:     chord.matrix = function(x) {
223:   d3.transpose = function(matrix) {
224:     if (!(n = matrix.length)) return [];
225:     for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) {
227:         row[j] = matrix[j][i];
5952:       return new d3_transform(t ? t.matrix : d3_transformIdentity);
6116:     var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
6125:           x += matrix[i][j];
6139:             return sortSubgroups(matrix[i][a], matrix[i][b]);
6148:           var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
6189:       if (!arguments.length) return matrix;
6190:       n = (matrix = x) && matrix.length;
1187:       point = point.matrixTransform(container.getScreenCTM().inverse());
TRONCO:R/visualization.R: [ ]
2377:     matrix = matrix(0, nrow = length(keys) + 3, ncol = 1)
407:     pheat.matrix = data.lifting(x,data)
1223: draw_matrix <- function(matrix,
98:     ##  This function sorts a matrix to enhance mutual exclusivity
198:             stop('"group.samples" should be matrix with sample names and group assignment.')
364:     data.lifting <- function(obj, matrix) {
375:                                        function(obj, matrix) {
377:                                            ## Are you sure (obj %in% # matrix)
380:                                            if (obj %in% matrix) {
385:                                        rownames(matrix)))]
386:                 sub.data = matrix[keys.subset, , drop = FALSE]
394:                 matrix[keys.subset, ] = sub.data 
404:         return(list(data=matrix, colors=map.gradient))
408:     map.gradient = pheat.matrix$colors
409:     data = pheat.matrix$data
785:     data = matrix(0, nrow = ngenes(x), ncol = ntypes(x))
882:         tmp = as.matrix(subdata[which(refcol == i), ]);
1060:         t = c(as.vector(as.matrix(annotation_col)), colnames(annotation_col)) 
1083:             c(as.vector(as.matrix(annotation_row)),
1161:         stop("Gaps do not match with matrix size")
1182:     dist = matrix(0, nrow = 2 * n - 1, ncol = 2, dimnames = list(NULL, c("x", "y"))) 
1230:         n = nrow(matrix)
1231:         m = ncol(matrix)
1248:                      gp = gpar(fill = matrix, col = border_color))
1383:     return(as.matrix(new))
1550: heatmap_motor <- function(matrix,
1585:            nrow = nrow(matrix),
1586:            ncol = ncol(matrix),
1634:         ## gt = heatmap_motor(matrix, cellwidth = cellwidth,
1650:             heatmap_motor(matrix,
1711:     ## Draw matrix.
1713:     elem = draw_matrix(matrix, border_color, gaps_row, gaps_col, fmat, fontsize_number, number_color)
1714:     res = gtable_add_grob(res, elem, t = 4, l = 3, clip = "off", name = "matrix")
1810:         mat = as.matrix(mat)
1811:         return(matrix(scale_vec_colours(as.vector(mat),
1972: #' @param mat numeric matrix of the values to be plotted.
1994: #' of the above it is assumed that a distance matrix is provided.
2032: #' the cells. If this is a matrix (with same dimensions as original matrix), the contents
2033: #' of the matrix are shown instead of original values.
2067: #' # Create test matrix
2068: #' test = matrix(rnorm(200), 20, 10)
2144:     ## Preprocess matrix.
2146:     mat = as.matrix(mat)
2172:     if (is.matrix(display_numbers) | is.data.frame(display_numbers)) {
2174:             stop("If display_numbers provided as matrix, its dimensions have to match with mat")
2177:         display_numbers = as.matrix(display_numbers)
2178:         fmat = matrix(as.character(display_numbers), nrow = nrow(display_numbers), ncol = ncol(display_numbers))
2182:             fmat = matrix(sprintf(number_format, mat), nrow = nrow(mat), ncol = ncol(mat))
2185:             fmat = matrix(NA, nrow = nrow(mat), ncol = ncol(mat))
2259:     ## Select only the ones present in the matrix.
2378:     rownames(matrix) = c(keys, 'soft', 'co-occurrence', 'other')
2379:     ## colnames(matrix) = paste(to, collapse = ':')
2380:     colnames(matrix) = to[1]
2420:     matrix['co-occurrence', ] = length(co.occurrences)
2421:     cat('Co-occurrence in #samples: ', matrix['co-occurrence', ], '\n')
2426:         matrix[keys[i], ] = length(intersect(to.samples, hard.pattern.samples[[keys[i]]])) 
2427:     cat('Hard exclusivity in #samples:', matrix[keys, ], '\n')  
2433:     matrix['other', ] = length(intersect(to.samples, union))
2434:     cat('Other observations in #samples:', matrix['other', ], '\n') 
2438:     matrix['soft', ] = length(to.samples) - colSums(matrix)
2439:     cat('Soft exclusivity in #samples:', matrix['soft', ], '\n')  
2443:     sector.color = rep('gray', nrow(matrix) + 1) 
2444:     link.color = rep('gray', nrow(matrix)) 
2446:     names(sector.color) = c(rownames(matrix), colnames(matrix))
2447:     names(link.color) = rownames(matrix)
2465:     idx.max = which(matrix == max(matrix))
2466:     link.style = matrix(0, nrow=nrow(matrix), ncol=ncol(matrix))
2467:     rownames(link.style) = rownames(matrix)
2468:     colnames(link.style) = colnames(matrix)
2482:     sector.color[colnames(matrix)] = as.colors(x)[as.events(x, genes = to[1], types=to[2])[, 'type' ]]
2489:         ## rownames(matrix)[i] = paste(paste(rep(' ', i), collapse = ''), events.names[i, 'event' ])
2491:             rownames(matrix)[i] = paste(paste(rep(' ', i), collapse = ''), events.names[i, 'event' ])
2492:         else rownames(matrix)[i] = events.names[i, 'event' ]
2494:         names(sector.color)[i] = rownames(matrix)[i]    
2499:         cat('Circlize matrix.\n')
2500:         print(matrix)
2508:         chordDiagram(matrix, 
2536:         layout(matrix(c(1,2,3,3), ncol = 2, byrow = TRUE), heights = c(4, 1))
2551:         print(matrix)
2553:         ## barplot(matrix[, 1], widths, space = 0)
2555:         rownames(matrix)[length(keys) + 1] = '2 or more\n(soft-exclusivity)'
2556:         rownames(matrix)[length(keys) + 2] = 'all together\n(co-occurrence)'
2558:         rownames(matrix)[nrow(matrix)] = 'none of the\nevents'
2560:         summary = matrix[ (length(keys) + 1):nrow(matrix), 1, drop = FALSE]
2561:         summary = rbind( sum(matrix[1:length(keys),]), summary)
2586:         exclus = matrix[1:length(keys), 1, drop = FALSE]
2617:                    c(paste(sum(matrix[1:length(keys) ,]), 'with 1 event (hard exclusivity)'),
2618:                      paste(matrix[length(keys) + 1, ],  'with 2 or more events'),
2619:                      paste(matrix[length(keys) + 2, ], 'with all events (co-occurrence)'),
2620:                      paste(matrix[length(keys) + 3, ], 'with no events')
epihet:R/epiNetwork.R: [ ]
180:         h <- WGCNA::labeledHeatmap(Matrix = moduleTraitCor,
51:     group.matrix <- compare.matrix[, group.samples]
53:     value.matrix <- group.matrix[DEH.loci, ]
58:     hit.matrix <- as.matrix(o)
60:         input.matrix = value.matrix
68:             mean.matrix <- foreach(i = geneid, .combine = cbind) %do%
173:         textMatrix <- paste(signif(moduleTraitCor, 2),
11: #' @param compare.matrix The comparison matrix generated from
17: #' for the samples in the comparison matrix. The row names should
35: #' heterogeneity matrix for patients
38: #' if node type is gene,it contains the epigenetic heterogeneity matrix for
41: epiNetwork <- function(node.type = "locus", DEH, compare.matrix,
49:     compare.matrix <- compare.matrix[which(compare.matrix$type == value), ]
50:     rownames(compare.matrix) <- compare.matrix$location
54:     value.matrix <- t(value.matrix)
61:         nSamples = nrow(value.matrix)
71:                   queryhit.id <- hit.matrix[which(hit.matrix[, 2] == i), 1]
73:                   epivalue <- value.matrix[, queryhit.loci$loci]
82:             mean.matrix <- mean.matrix[, colSums(mean.matrix) != 0]
83:             nSamples <- dim(mean.matrix)[1]
84:             input.matrix <- mean.matrix
90:     sft <- WGCNA::pickSoftThreshold(input.matrix, powerVector = powers,
131:     net <- WGCNA::blockwiseModules(input.matrix, power = softpowers,
157:         module <- data.frame(gene = colnames(input.matrix),
161:     MEs0 <- WGCNA::moduleEigengenes(input.matrix, moduleColors)$eigengenes
194:         geneset <- data.frame(DEHloci = mcols(userset[hit.matrix[,1]])$loci,
195:             gene = mcols(annotation.obj[hit.matrix[,2]])$name,
262:         result <- list(epimatrix = input.matrix, module = module,
265:         result <- list(epimatrix = input.matrix, module = module)
12: #' the compMatrix() function.
175:         dim(textMatrix) <- dim(moduleTraitCor)
183:             colors = WGCNA::blueWhiteRed(50), textMatrix = textMatrix,
scde:R/functions.R: [ ]
6015:             matrix <- gcl$vmap[rev(gcl$row.order), results$hvc$order, drop = FALSE]
6083:                        matrix <- results$rcm[rev(results$tvc$order), results$hvc$order]
6324:                        matrix <- results$rcm[rev(results$tvc$order), results$hvc$order]
1079: winsorize.matrix <- function(mat, trim) {
3405: calculate.joint.posterior.matrix <- function(lmatl, n.samples = 100, bootstrap = TRUE, n.cores = 15) {
3422: calculate.batch.joint.posterior.matrix <- function(lmatll, composition, n.samples = 100, n.cores = 15) {
3810: get.exp.posterior.matrix <- function(m1, counts, marginals, grid.weight = rep(1, nrow(marginals)), rescale = TRUE, n.cores =...(17 bytes skipped)...
3826: get.exp.logposterior.matrix <- function(m1, counts, marginals, grid.weight = rep(1, nrow(marginals)), rescale = TRUE, n.cores =...(6 bytes skipped)...
109: ##' Filter counts matrix
111: ##' Filter counts matrix based on gene and cell requirements
113: ##' @param counts read count matrix. The rows correspond to genes, columns correspond to individual cells
118: ##' @return a filtered read count matrix
145: ##' @param counts read count matrix. The rows correspond to genes (should be named), columns correspond to individual cells. The matrix should contain integer counts
163: ##' @return a model matrix, with rows corresponding to different cells, and columns representing different parameters of the d...(16 bytes skipped)...
184: ...(114 bytes skipped)...thod is designed to work on read counts - do not pass normalized read counts (e.g. FPKM values). If matrix contains read counts, but they are stored as numeric values, use counts<-apply(counts,2,function(x)...(49 bytes skipped)...
208: ##' @param counts count matrix
228:     fpkm <- log10(exp(as.matrix(fpkm))+1)
229:     wts <- as.numeric(as.matrix(1-fail[, colnames(fpkm)]))
262: ##' @param counts read count matrix
264: ...(41 bytes skipped)...e two groups of cells being compared. The factor entries should correspond to the rows of the model matrix. The factor should have two levels. NAs are allowed (cells will be omitted from comparison).
265: ##' @param batch a factor (corresponding to rows of the model matrix) specifying batch assignment of each cell, to perform batch correction
284: ##' \code{difference.posterior} returns a matrix of estimated expression difference posteriors (rows - genes, columns correspond to different magnit...(64 bytes skipped)...
305:         stop("ERROR: provided count data does not cover all of the cells specified in the model matrix")
309:     counts <- as.matrix(counts[, ci])
416: ##' @param models model matrix
417: ##' @param counts count matrix
513: ##' @param counts read count matrix
516: ##' @param batch a factor describing which batch group each cell (i.e. each row of \code{models} matrix) belongs to
523: ##' @return \subsection{default}{ a posterior probability matrix, with rows corresponding to genes, and columns to expression levels (as defined by \code{prior$x})
525: ...(24 bytes skipped)...ndividual.posterior.modes}{ a list is returned, with the \code{$jp} slot giving the joint posterior matrix, as described above. The \code{$modes} slot gives a matrix of individual expression posterior mode values on log scale (rows - genes, columns -cells)}
526: ...(85 bytes skipped)...st} slot giving a list of individual posterior matrices, in a form analogous to the joint posterior matrix, but reported on log scale }
538: ...(43 bytes skipped)...counts))) { stop("ERROR: provided count data does not cover all of the cells specified in the model matrix") }
545:     counts <- as.matrix(counts[, ci, drop = FALSE])
571:     # prepare matrix models
574:     mm <- matrix(NA, nrow(models), length(mn))
575:     mm[, which(!is.na(mc))] <- as.matrix(models[, mc[!is.na(mc)], drop = FALSE])
645: # models - entire model matrix, or a subset of cells (i.e. select rows) of the model matrix for which the estimates should be obtained
647: # return - a matrix of log(FPM) estimates with genes as rows and cells  as columns (in the model matrix order).
653: ##' @param counts count matrix
655: ##' @return a matrix of expression magnitudes on a log scale (rows - genes, columns - cells)
666: ...(43 bytes skipped)...counts))) { stop("ERROR: provided count data does not cover all of the cells specified in the model matrix") }
672: # magnitudes can either be a per-cell matrix or a single vector of values which will be evaluated for each cell
676: ##' Returns estimated drop-out probability for each cell (row of \code{models} matrix), given either an expression magnitude
678: ##' @param magnitudes a vector (\code{length(counts) == nrows(models)}) or a matrix (columns correspond to cells) of expression magnitudes, given on a log scale
679: ##' @param counts a vector (\code{length(counts) == nrows(models)}) or a matrix (columns correspond to cells) of read counts from which the expression magnitude should be estimate...(1 bytes skipped)...
681: ##' @return a vector or a matrix of drop-out probabilities
704:     if(is.matrix(magnitudes)) { # a different vector for every cell
705: ...(55 bytes skipped)...es))) { stop("ERROR: provided magnitude data does not cover all of the cells specified in the model matrix") }
730: ##' @param counts read count matrix (must contain the row corresponding to the specified gene)
732: ##' @param groups a two-level factor specifying between which cells (rows of the models matrix) the comparison should be made
733: ##' @param batch optional multi-level factor assigning the cells (rows of the model matrix) to different batches that should be controlled for (e.g. two or more biological replicates). The e...(224 bytes skipped)...
759:     counts <- as.matrix(counts[gene, ci, drop = FALSE])
819:         layout(matrix(c(1:3), 3, 1, byrow = TRUE), heights = c(2, 1, 2), widths = c(1), FALSE)
926: ##' @param counts count matrix
927: ...(8 bytes skipped)...am reference a vector of expression magnitudes (read counts) corresponding to the rows of the count matrix
936: ##' @return matrix of scde models
988:         #l <- layout(matrix(seq(1, 4*length(ids)), nrow = length(ids), byrow = TRUE), rep(c(1, 1, 1, 0.5), length(ids)), rep(1,...(23 bytes skipped)...
989:         l <- layout(matrix(seq(1, 4), nrow = 1, byrow = TRUE), rep(c(1, 1, 1, 0.5), 1), rep(1, 4), FALSE)
1000:         # make a joint model matrix
1011: ##' Determine principal components of a matrix using per-observation/per-variable weights
1015: ##' @param mat matrix of variables (columns) and observations (rows)
1026: ##' @return a list containing eigenvector matrix ($rotation), projections ($scores), variance (weighted) explained by each component ($var), total (...(45 bytes skipped)...
1030: ##' mat <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random matrix
1032: ##' matw <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random weight matrix
1040:       stop("bwpca: weight matrix contains NaN values")
1043:       stop("bwpca: value matrix contains NaN values")
1046:         matw <- matrix(1, nrow(mat), ncol(mat))
1061: ##' Winsorize matrix
1065: ##' @param mat matrix
1068: ##' @return Winsorized matrix
1072: ##' mat <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)  # random matrix
1075: ##' win.mat <- winsorize.matrix(mat, 0.1)
1100: ##' @param counts count matrix (integer matrix, rows- genes, columns- cells)
1133: ...(114 bytes skipped)...thod is designed to work on read counts - do not pass normalized read counts (e.g. FPKM values). If matrix contains read counts, but they are stored as numeric values, use counts<-apply(counts,2,function(x)...(49 bytes skipped)...
1162:         #celld <- WGCNA::cor(log10(matrix(as.numeric(as.matrix(ca)), nrow = nrow(ca), ncol = ncol(ca))+1), method = cor.method, use = "p", nThreads = n.cores)
1164:             celld <- WGCNA::cor(sqrt(matrix(as.numeric(as.matrix(ca[, ids])), nrow = nrow(ca), ncol = length(ids))), method = cor.method, use = "p", nThreads = n.co...(4 bytes skipped)...
1166:             celld <- stats::cor(sqrt(matrix(as.numeric(as.matrix(ca[, ids])), nrow = nrow(ca), ncol = length(ids))), method = cor.method, use = "p")
1174:         # TODO: correct for batch effect in cell-cell similarity matrix
1176:             # number batches 10^(seq(0, n)) compute matrix of id sums, NA the diagonal,
1178:             bm <- matrix(bid, byrow = TRUE, nrow = length(bid), ncol = length(bid))+bid
1181:             # use tapply to calculate means shifts per combination reconstruct shift vector, matrix, subtract
1239:                     l <- layout(matrix(seq(1, 4), nrow = 1, byrow = TRUE), rep(c(1, 1, 1, ifelse(local.theta.fit, 1, 0.5)), 1), rep(1, 4),...(7 bytes skipped)...
1263:     # make a joint model matrix
1278: ##' @param models model matrix (select a subset of rows to normalize variance within a subset of cells)
1279: ##' @param counts read count matrix
1288: ##' @param weight.k k value to use in the final weight matrix
1294: ##' @param gene.length optional vector of gene lengths (corresponding to the rows of counts matrix)
1307: ##' \item{matw} { weight matrix corresponding to the expression matrix}
1334:         stop(paste("supplied count matrix (cd) is missing data for the following cells:[", paste(rownames(models)[!rownames(models) %in% coln...(44 bytes skipped)...
1343:         if(verbose) { cat("Winsorizing count matrix ... ") }
1345:         #tfpm <- log(winsorize.matrix(exp(fpm), trim = trim))
1346:         tfpm <- winsorize.matrix(fpm, trim)
1430:     if(verbose) { cat("calculating weight matrix ... ") }
1450:     # calculate batch-specific version of the weight matrix if needed
1695:     # use milder weight matrix
1787: ##' (weighted) projection of the expression matrix onto a specified aspect (some pattern
1794: ##' @param center whether the matrix should be re-centered following pattern subtraction
1796: ##' @return a modified varinfo object with adjusted expression matrix (varinfo$mat)
1850: ##' @param center whether the expression matrix should be recentered
1989: ##' Determine de-novo gene clusters, their weighted PCA lambda1 values, and random matrix expectation.
1995: ##' @param n.samples number of randomly generated matrix samples to test the background distribution of lambda1 on
2004: ...(10 bytes skipped)... secondary.correlation whether clustering should be performed on the correlation of the correlation matrix instead
2014: ##' \item{varm} {standardized lambda1 values for each randomly generated matrix cluster}
2036:         mat <- winsorize.matrix(mat, trim = trim)
2060:                 gd <- as.dist(1-WGCNA::cor(as.matrix(gd), method = "p", nThreads = n.cores))
2062:                 gd <- as.dist(1-cor(as.matrix(gd), method = "p"))
2103:                 # generate random normal matrix
2105:                 m <- matrix(rnorm(nrow(mat)*n.cells), nrow = nrow(mat), ncol = n.cells)
2113:                     m <- winsorize.matrix(m, trim = trim)
2124:                         gd <- as.dist(1-WGCNA::cor(as.matrix(gd), method = "p", nThreads = 1))
2126:                         gd <- as.dist(1-cor(as.matrix(gd), method = "p"))
2230: ##' \item{xv} {a matrix of normalized aspect patterns (rows- significant aspects, columns- cells}
2231: ##' \item{xvw} { corresponding weight matrix }
2505: ##' @param distance distance matrix
2569:     if(trim > 0) { xvl$d <- winsorize.matrix(xvl$d, trim) } # trim prior to determining the top sets
2593: ...(35 bytes skipped)...f whether to return just the hclust result or a list containing the hclust result plus the distance matrix and gene values
2690: ##' @param mat Numeric matrix
2694: ##' @param row.cols  Matrix of row colors.
2695: ##' @param col.cols  Matrix of column colors. Useful for visualizing cell annotations such as batch labels.
2730: ##' @param col.cols  Matrix of column colors. Useful for visualizing cell annotations such as batch labels. Default NULL.
2840:         layout(matrix(c(1:3), 3, 1, byrow = TRUE), heights = c(2, 1, 2), widths = c(1), FALSE)
2953:                 m1@concomitant@x <- matrix()
2955:                     mod@x <- matrix()
2956:                     mod@y <- matrix()
3083: # vil - optional binary matrix (corresponding to counts) with 0s marking likely drop-out observations
3118:     f <- calcNormFactors(as.matrix(counts[gis, !is.na(groups)]), ...)
3127:     fpkm <- log10(exp(as.matrix(fpkm))+1)
3128:     wts <- as.numeric(as.matrix(1-fail[, colnames(fpkm)]))
3218:         # pair cell name matrix
3267:             m1@concomitant@x <- matrix()
3269:                 mod@x <- matrix()
3270:                 mod@y <- matrix()
3327:             #l <- layout(matrix(seq(1, 4*length(ids)), nrow = length(ids), byrow = TRUE), rep(c(1, 1, 1, 0.5), length(ids)), rep(1,...(23 bytes skipped)...
3328:             l <- layout(matrix(seq(1, 4), nrow = 1, byrow = TRUE), rep(c(1, 1, 1, ifelse(linear.fit, 1, 0.5)), 1), rep(1, 4), FALS...(2 bytes skipped)...
3344:         # make a joint model matrix
3386:             df <- get.exp.logposterior.matrix(group.ifm[[nam]], dat[, nam], marginals, n.cores = inner.cores, grid.weight = prior$grid.weight)
3403: # calculate joint posterior matrix for a given group of experiments
3420: # lmatll - list of posterior matrix lists (as obtained from calculate.posterior.matrices)
3467: # calculate a joint posterior matrix with bootstrap
3589:     #matrix(cbind(ifelse(rdf$count<= zero.count.threshold, 0.95, 0.05), ifelse(rdf$count > zero.count.threshold...(15 bytes skipped)...
3604:         l <- layout(matrix(c(1:4), 1, 4, byrow = TRUE), c(1, 1, 1, 0.5), rep(1, 4), FALSE)
3654:     fdf <- data.frame(y = rowMeans(matrix(log10(rdf$fpm[1:(n.zero.windows*bw)]+1), ncol = bw, byrow = TRUE)), zf = rowMeans(matrix(as.integer(rdf$cluster[1:(n.zero.windows*bw)] == 1), ncol = bw, byrow = TRUE)))
3663:         cm0 <- exp(model.matrix(mt, data = mf) %*% m1@concomitant@coef)
3716: # df: count matrix
3717: # xr: expression level for each row in the matrix
3740: # counts - observed count matrix corresponding to the models
3780:     cm0 <- exp(model.matrix(mt, data = mf) %*% m1@concomitant@coef)
3797:     cm0 <- model.matrix(mt, data = mf) %*% m1@concomitant@coef
3805: # returns a matrix of posterior values, with rows corresponding to genes, and
3812:     #message(paste("get.exp.posterior.matrix() :", round((1-length(uc)/length(counts))*100, 3), "% savings"))
3828:     #message(paste("get.exp.logposterior.matrix() :", round((1-length(uc)/length(counts))*100, 3), "% savings"))
3841: # similar to get.exp.posterior.matrix(), but returns inverse ecdf list
3848: # similar to get.exp.posterior.matrix(), but returns inverse ecdf list
3871:     cm0 <- exp(model.matrix(mt, data = mf) %*% m1@concomitant@coef)
4138:         m <- matrix(sapply(components, function(x) x@logLik(model@x, model@y)), nrow = nrow(model@y))
4141:         m <- matrix(do.call(cbind, lapply(seq_along(components), function(i) {
4175:         m <- matrix(sapply(components, function(x) x@logLik(model@x, model@y)), nrow = nrow(model@y))
4178:         m <- matrix(do.call(cbind, lapply(seq_along(components), function(i) {
4223:         m <- matrix(sapply(components, function(x) x@logLik(model@x, model@y)), nrow = nrow(model@y))
4226:         m <- matrix(do.call(cbind, lapply(seq_along(components), function(i) {
4488:     x <- as.matrix(x)
4490:     ynames <- if (is.matrix(y))
4611:                 stop(gettextf("X matrix has rank %d, but only %d observations",
4711:         fit$qr <- as.matrix(fit$qr)
4718:         Rmat <- as.matrix(Rmat)
4856:     if (!is.matrix(x)) {
5008: # weight matrix should have the same dimensions as the data matrix
5154:         stop("'x' must be a numeric matrix")
5259:         if(is.matrix(ColSideColors)) {
5261:                 stop("'ColSideColors' matrix must have the same number of columns as length ncol(x)")
5306:         if(is.matrix(ColSideColors)) {
5307:             image(t(matrix(1:length(ColSideColors), byrow = TRUE, nrow = nrow(ColSideColors), ncol = ncol(ColSideColors))), co...(70 bytes skipped)...
5572:         mat <- winsorize.matrix(mat, trim = trim)
5583:     dd <- as.dist(1-abs(cor(t(as.matrix(d)))))
5599:         vd <- as.dist(1-cor(as.matrix(d)))
5669: ##' @param colcols optional column color matrix
5678: ##' @param box whether to draw a box around the plotted matrix
5680: ##' @param return.details whether the function should return the matrix as well as full PCA info instead of just PC1 vector
5726:         mat <- winsorize.matrix(mat, trim = trim)
5766:             mat <- winsorize.matrix(mat, trim = trim)
5791:     dd <- as.dist(1-abs(cor(t(as.matrix(d)))))
5807:         vd <- as.dist(1-cor(as.matrix(d)))
5973: ##' @field mat Matrix of posterior mode count estimates
5974: ##' @field matw Matrix of weights associated with each estimate in \code{mat}
6016:             matrix <- list(data = as.numeric(t(matrix)),
6017:                            dim = dim(matrix),
6018:                            rows = rownames(matrix),
6019:                            cols = colnames(matrix),
6024:             ol <- list(matrix = matrix)
6026:                 rcmvar <- matrix(gcl$rotation[rev(gcl$row.order), , drop = FALSE], ncol = 1)
6033:                 colcols <- matrix(gcl$oc[results$hvc$order], nrow = 1)
6084:                        matrix <- list(data = as.numeric(t(matrix)),
6085:                                       dim = dim(matrix),
6086:                                       rows = rownames(matrix),
6087:                                       cols = colnames(matrix),
6090:                                       range = range(matrix)
6095:                        rcmvar <- matrix(apply(results$rcm[rev(results$tvc$order), , drop = FALSE], 1, var), ncol = 1)
6105:                        ol <- list(matrix = matrix, rowcols = rowcols, colcols = colcols, coldend = treeg, trim = trim)
6159:                        patc <- .Call("matCorr", as.matrix(t(mat)), as.matrix(pat, ncol = 1) , PACKAGE = "scde")
6325:                        body <- paste(capture.output(write.table(round(matrix, 1), sep = "\t")), collapse = "\n")
1081:     wm <- .Call("winsorizeMatrix", mat, trim, PACKAGE = "scde")
1755:         ##   # construct mat multiplier submatrix
3723:         x <- FLXgetModelmatrix(m1@model[[1]], edf, m1@model[[1]]@formula)
3724:         #cx <- FLXgetModelmatrix(m1@concomitant, edf, m1@concomitant@formula)
BioNERO:R/gcn_inference.R: [ ]
428:     hm <- WGCNA::labeledHeatmap(Matrix = modtraitcor,
991:                 matrix <- list_mat[[x]]
131:     cor_matrix <- calculate_cor_adj(cor_method, norm.exp, SFTpower, net_type)$cor
132:     adj_matrix <- calculate_cor_adj(cor_method, norm.exp, SFTpower, net_type)$adj
957:     cor_matrix <- net$correlation_matrix
407:     textMatrix <- paste(signif(modtraitcor, 2), modtraitsymbol, sep = "")
94: #'   \item Adjacency matrix
99: #'   \item Correlation matrix
130:     if(verbose) { message("Calculating adjacency matrix...") }
134:     #Convert to matrix
135:     gene_ids <- rownames(adj_matrix)
136:     adj_matrix <- matrix(adj_matrix, nrow=nrow(adj_matrix))
137:     rownames(adj_matrix) <- gene_ids
138:     colnames(adj_matrix) <- gene_ids
140:     #Calculate TOM from adjacency matrix
141:     if(verbose) { message("Calculating topological overlap matrix (TOM)...") }
143:     TOM <- WGCNA::TOMsimilarity(adj_matrix, TOMType = tomtype)
207:     kwithin <- WGCNA::intramodularConnectivity(adj_matrix, new.module_colors)
209:     result.list <- list(adjacency_matrix = adj_matrix,
214:                         correlation_matrix = cor_matrix,
295:     expr <- as.matrix(t(norm.exp))
312:     # Define a matrix of labels for the original and all resampling runs
313:     labels <- matrix(0, nGenes, nRuns + 1)
359: #' @param cex.text Font size for numbers inside matrix. Default: 0.6.
395:     modtraitcor <- cor(as.matrix(MEs), trait, use = "p", method=cor_method)
463: #'   \item{filtered_corandp}{Filtered matrix of correlation and p-values}
464: #'   \item{raw_GS}{Raw matrix of gene significances}
493:     GS <- cor(as.matrix(t(final_exp)), trait, use = "p")
514:     p <- ComplexHeatmap::pheatmap(as.matrix(GS), border_color = NA,
610:         fmat <- matrix(c(GinSet, RinSet, GninSet, RninSet), nrow = 2,
865:     edges <- net$correlation_matrix
888: #' Get edge list from an adjacency matrix for a group of genes
910: #' the correlation matrix was calculated. Only required
919: #' edge lists by filtering the original correlation matrix by the thresholds
956:     # Define objects containing correlation matrix and data frame of genes and modules
963:         cor_matrix <- cor_matrix[keep, keep]
968:         cor_matrix <- cor_matrix[genes, genes]
971:     # Should we filter the matrix?
973:         # Create edge list from correlation matrix
974:         edges <- cormat_to_edgelist(cor_matrix)
987:             list_mat <- replicate(length(cutoff), cor_matrix, simplify = FALSE)
992:                 matrix[matrix < cutoff[x] ] <- NA
993:                 diag(matrix) <- 0
996:                 degree <- rowSums(matrix, na.rm=TRUE)
999:                 matrix[lower.tri(matrix, diag=TRUE)] <- NA
1001:                 # Convert symmetrical matrix to edge list (Gene1, Gene2, Weight)
1002:                 matrix <- na.omit(data.frame(as.table(matrix), stringsAsFactors=FALSE))
1003:                 result <- list(matrix=matrix, degree=degree)
1027:                 stop("Please, specify the number of samples used to calculate the correlation matrix")
1048:         # Create edge list from correlation matrix without filtering
1049:         edgelist <- cormat_to_edgelist(cor_matrix)
408:     dim(textMatrix) <- dim(modtraitcor)
412:         textMatrix <- t(textMatrix)
433:                                 textMatrix = textMatrix, setStdMargins = FALSE,
MotifDb:inst/scripts/import/uniprobe/import.R: [ ]
231:       matrix = matrices [[m]]
73:   matrix.start.lines = grep ('A\\s*[:\\|]', text)
79:   pwm.matrix = parsePWMfromText (lines)
148:     matrix.start.lines = grep ('A:', text)
153:     pwm.matrix = parsePWMfromText (lines.of.text)
157:     matrix.name <- paste(name.tokens[(token.count-1):token.count], collapse="/")
195:     matrix.name = names (matrices) [m]
33: createMatrixNameUniqifier = function (matrix)
36:   write (as.character (matrix), file=temporary.file)
52:   result = matrix (nrow=4, ncol=column.count, byrow=TRUE, dimnames=list (c ('A', 'C', 'G', 'T'), 1:column.count))
74:   stopifnot (length (matrix.start.lines) == 1)
75:   #printf ('%50s: %s', filename, list.to.string (matrix.start.lines))
76:   start.line = matrix.start.lines [1]
80:   return (pwm.matrix)
149:     stopifnot (length (matrix.start.lines) == 1)
150:     start.line = matrix.start.lines [1]
158:     matrices [[matrix.name]] = pwm.matrix
184: # and update matrix names
196:     #printf ('%d: %s', m, matrix.name)
197:     native.name.raw = gsub ('All_PWMs/', '', matrix.name)
225:       # the organism-dataSource-geneIdentifier matrix name.
232:       uniqifier = createMatrixNameUniqifier (matrix)
42: } # createMatrixNameUniqifier
ISAnalytics:R/internal-functions.R: [ ]
1590:         matrix <- .import_single_matrix(x)
1481: .import_single_matrix <- function(path, to_exclude = NULL, separator = "\t") {
3869:     matrix_desc <- df %>%
4083:             sub_matrix <- matrix_desc[, seq(from = t1, to = t2, by = 1)]
4129:             sub_matrix <- matrix_desc[, seq(from = t1, to = t2, by = 1)]
1981: .join_matrix_af <- function(df, association_file, date_col) {
86: # Finds experimental columns in an integration matrix.
89: # standard integration matrix columns, if there are returns their names.
108: # Checks if the integration matrix is annotated or not.
123: #### ---- Internals for matrix import ----####
125: #---- USED IN : import_single_Vispa2Matrix ----
149: # Reads an integration matrix using data.table::fread
187: # Reads an integration matrix using readr::read_delim
695:     matrix_type,
697:     multi_quant_matrix) {
705:     stopifnot(is.character(matrix_type) & matrix_type %in% c(
709:     stopifnot(is.logical(multi_quant_matrix) & length(multi_quant_matrix) == 1)
1196: # @param matrix_type The matrix_type to lookup (one between "annotated" or
1208:     matrix_type) {
1219:     ms <- if (matrix_type == "annotated") {
1220:         .matrix_annotated_suffixes()
1222:         .matrix_not_annotated_suffixes()
1231:             "_matrix",
1466: # A single threaded and simplified version of import_single_Vispa2Matrix
1471: # and to reshape the entire matrix directly
1820:     matrix_type,
1826:         matrix_type
1942: # Checks if association file contains more information than the matrix.
1945: # the examined matrix there are additional CompleteAmplificationIDs contained
1946: # in the association file that weren't included in the integration matrix (for
1971: # Produces a joined tibble between the sequence count matrix and the
1995: # @param joined_df The joined tibble obtained via `.join_matrix_af`
2139: # for multi quantification matrix)
2182: # for multi quantification matrix)
2251: # for multi quantification matrix)
2292: # for multi quantification matrix)
2376: # (obtained via `.join_matrix_af`)
2377: # @param after The final matrix obtained after collision processing
2427: # Internal for obtaining summary info about the input sequence count matrix
2454:     ## Joined is the matrix already joined with metadata
2583: # @param x The list of matrices to aggregate. If a single matrix has to be
2584: # supplied it must be enclosed in a list. For example `x = list(matrix)`.
2658: # meaning a subset of an integration matrix in which all rows
2661: # @param x An integration matrix subset (see description)
2675: # @return A named list with recalibrated matrix and recalibration map.
2721:             return(list(recalibrated_matrix = x, map = map_recalibr))
2840:     list(recalibrated_matrix = x, map = map_recalibr)
3868:     # --- OBTAIN MATRIX (ALL TPs)
3883:         as.matrix()
3884:     # --- OBTAIN MATRIX (STABLE TPs)
3903:             as.matrix()
3908:     timecaptures <- length(colnames(matrix_desc))
3915:         matrix_desc = matrix_desc,
3924:             matrix_desc = patient_slice_stable,
3935:         matrix_desc = matrix_desc,
3943:             matrix_desc = patient_slice_stable,
3953:     estimate_consecutive_m0 <- if (ncol(matrix_desc) > 1) {
3955:             matrix_desc = matrix_desc,
3963:     estimate_consecutive_mth <- if (stable_tps & ncol(matrix_desc) > 2) {
3964:         # - Note: pass the whole matrix, not only stable slice
3966:             matrix_desc = matrix_desc,
3987: .closed_m0_est <- function(matrix_desc, timecaptures, cols_estimate_mcm,
3990:     models0 <- Rcapture::closedp.0(matrix_desc,
3998:         colnames(matrix_desc)[1],
4002:         colnames(matrix_desc)[ncol(matrix_desc)],
4032: .closed_mthchaobc_est <- function(matrix_desc, timecaptures, cols_estimate_mcm,
4034:     mthchaobc <- Rcapture::closedp.bc(matrix_desc,
4042:         colnames(matrix_desc)[1],
4046:         colnames(matrix_desc)[ncol(matrix_desc)],
4076: .consecutive_m0bc_est <- function(matrix_desc, cols_estimate_mcm, subject) {
4078:     indexes <- seq(from = 1, to = ncol(matrix_desc) - 1, by = 1)
4085:                 colnames(sub_matrix)[1],
4089:                 colnames(sub_matrix)[ncol(sub_matrix)],
4092:             patient_trend_M0 <- Rcapture::closedp.bc(sub_matrix,
4123: .consecutive_mth_est <- function(matrix_desc, cols_estimate_mcm, subject) {
4124:     indexes_s <- seq(from = 1, to = ncol(matrix_desc) - 2, by = 1)
4131:                 colnames(sub_matrix)[1],
4135:                 colnames(sub_matrix)[ncol(sub_matrix)],
4138:             patient_trend_Mth <- Rcapture::closedp.bc(sub_matrix,
1509:         rlang::abort(.malformed_ISmatrix_error(),
interactiveDisplay:inst/www/js/d3.v2.js: [ ]
5000:     var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
5001:     chord.matrix = function(x) {
2751:   d3.transpose = function(matrix) {
2752:     return d3.zip.apply(d3, matrix);
3138:       return new d3_transform(t ? t.matrix : d3_transformIdentity);
4937:           x += matrix[i][j];
4951:             return sortSubgroups(matrix[i][a], matrix[i][b]);
4960:           var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
5002:       if (!arguments.length) return matrix;
5003:       n = (matrix = x) && matrix.length;
651:       point = point.matrixTransform(container.getScreenCTM().inverse());
pcxn:R/pcxn_analyze.R: [ ]
84:                 matrix <- pathCor_pathprint_v1.2.3_dframe
89:                 matrix <- pathCor_pathprint_v1.2.3_unadjusted_dframe 
98:                 matrix <- pathCor_Hv5.1_dframe
102:                 matrix <- pathCor_Hv5.1_unadjusted_dframe 
111:                 matrix <- pathCor_CPv5.1_dframe
115:                 matrix <- pathCor_CPv5.1_unadjusted_dframe 
123:                 matrix <- pathCor_GOBPv5.1_dframe
127:                 matrix <- pathCor_GOBPv5.1_unadjusted_dframe 
173:         step1_matrix <-
174:             subset(matrix, abs(PathCor) >= min_abs_corr & p.value <= max_pval)
178:             temp_cor <- subset(step1_matrix,(Pathway.A == unused_genesets[i]
199:         # create matrix with geneset groups
210:         step2_matrix <-
211:             subset(step1_matrix, Pathway.A %in% interesting_genesets &
217:                         top, " top correlated genesets, ", dim(step2_matrix)[1],
224:                         top, " top correlated genesets, ", dim(step2_matrix)[1],
227:         po = new("pcxn",type = "pcxn_analyze", data = as.matrix(step2_matrix),
TRONCO:R/as.functions.R: [ ]
900:     matrix = NULL
1013:     as.adj.matrix(x,
1289:     as.adj.matrix(x,
646: as.adj.matrix <- function(x,
916:     matrix.to.df <- function(m) {    
1035:     matrix.to.df <- function(z) {   
1213:     matrix.to.df <- function(z) {   
1217:         prederr.matrix = x$kfold[[z]]$prederr
1297:     matrix.to.df <- function(z) {  
1303:         posterr.matrix = get(z, x$kfold)$posterr
1967:     adj.matrix = get(model, as.adj.matrix(x, models = model))
21: #' @return A TRONCO genotypes matrix.
87: #' @return A matrix with 2 columns (event type, gene name) for the events found.
121: #' @return A matrix with 1 column annotating stages and rownames as sample IDs.
143: #' @return A matrix with 1 column annotating stages and rownames as sample IDs.
180: #' @return A matrix, subset of \code{as.genotypes(x)} with colnames substituted  with events' types.
627: #' Extract the adjacency matrix of a TRONCO model. The matrix is indexed with colnames/rownames which 
629: #' specify a subset of events to build the matrix, a subset of models if multiple reconstruction have
630: #' been performed. Also, either the prima facie matrix or the post-regularization matrix can be extracted.
634: #' as.adj.matrix(test_model)
635: #' as.adj.matrix(test_model, events=as.events(test_model)[5:15,])
636: #' as.adj.matrix(test_model, events=as.events(test_model)[5:15,], type='pf')
638: #' @title as.adj.matrix
642: #' @param type Either the prima facie ('pf') or the post-regularization ('fit') matrix, 'fit' by default.
643: #' @return The adjacency matrix of a TRONCO model. 
644: #' @export as.adj.matrix
667:             mat = m[[i]]$adj.matrix$adj.matrix.fit
669:             mat = m[[i]]$adj.matrix$adj.matrix.pf
683: #' Extract the marginal probabilities from a TRONCO model. The return matrix is indexed with rownames which 
685: #' specify a subset of events to build the matrix, a subset of models if multiple reconstruction have
709:         stop('Events should have colnames to access the adjacency matrix - use \'as.events\' function?')
734: #' Extract the joint probabilities from a TRONCO model. The return matrix is indexed with rownames/colnames which 
736: #' specify a subset of events to build the matrix, a subset of models if multiple reconstruction have
761:         stop('Events should have colnames to access the adjacency matrix - use \'as.events\' function?')
787: #' Extract the conditional probabilities from a TRONCO model. The return matrix is indexed with rownames which 
789: #' specify a subset of events to build the matrix, a subset of models if multiple reconstruction have
814:         stop('Events should have colnames to access the adjacency matrix - use \'as.events\' function?')
903:         matrix$pf = x$adj.matrix.prima.facie   
905:         matrix =
906:             as.adj.matrix(x,
911:     matrix = lapply(matrix, keysToNames, x = x)
981:     return(lapply(matrix, matrix.to.df))
1012:     matrix = 
1019:     matrix = lapply(matrix, keysToNames, x = x)
1036:         m = matrix[[z]]
1117:     res = lapply(seq_along(matrix), matrix.to.df)
1118:     names(res) = names(matrix)
1219:             names(prederr.matrix) = lapply(names(prederr.matrix), function(k) { nameToKey(x, k) })
1220:             return(prederr.matrix)
1225:         df$prederr = t(as.data.frame(prederr.matrix)) # values
1248:     res = lapply(seq_along(models), matrix.to.df)
1288:     matrix = 
1295:     matrix = lapply(matrix, keysToNames, x = x)
1302:         m = matrix[[z]]
1306:             rownames(posterr.matrix) = lapply(rownames(posterr.matrix), function(k) { nameToKey(x, k) })
1307:             colnames(posterr.matrix) = lapply(colnames(posterr.matrix), function(k) { nameToKey(x, k) })
1308:             return(posterr.matrix)
1312:         posterr.matrix = keysToNames(posterr.matrix, x = x)
1333:                     val = posterr.matrix[[select,selected]]
1369:     res = lapply(models, matrix.to.df)
1370:     names(res) = names(matrix)
1802: #' Convert colnames/rownames of a matrix into intelligible event names, e.g., change a key G23 in 'Mutation KRAS'.
1807: #' adj_matrix = as.adj.matrix(test_model, events=as.events(test_model)[5:15,])$capri_bic
1808: #' keysToNames(test_model, adj_matrix)
1813: #' @param matrix A matrix with colnames/rownames which represent genotypes keys. 
1814: #' @return The matrix with intelligible colnames/rownames. 
1817: keysToNames <- function(x, matrix) {
1819:     if (!is.matrix(matrix)
1820:         || any(is.null(colnames(matrix)))
1821:         || any(is.null(rownames(matrix))))
1822:         stop('"matrix" should be a matrix with rownames/colnames.')
1830:     colnames(matrix) = sapply(colnames(matrix), resolve)
1831:     rownames(matrix) = sapply(rownames(matrix), resolve)
1832:     return(matrix)
1840: #' adj_matrix = as.adj.matrix(test_model, events=as.events(test_model)[5:15,])$bic
1961:     genotypes = as.matrix(genotypes)
1968:     adj.matrix = keysToNames(x, adj.matrix)
1975:     for (from in rownames(adj.matrix)) {
1976:         for (to in colnames(adj.matrix)) {
1977:             if (adj.matrix[from, to] == 1) {
RGMQL:R/Utils.R: [ ]
82:         matrix <- matrix(new_value)
80:     aggregate_matrix <- t(vapply(meta_data, function(x) {
86:     metadata_matrix <- cbind(m_names,aggregate_matrix)
92:     cond_matrix <- NULL
85:     m_names <- matrix(names)
95:         cond_matrix <- rbind(cond_matrix, def)
99:         cond_matrix <- rbind(cond_matrix, exact)
103:         cond_matrix <- rbind(cond_matrix, full)
104:     cond_matrix
MotifDb:misc/hocomoco-v11/importV11.R: [ ]
106:     matrix <- matrices[[matrix.id]]
75:   matrix.names <- sapply(pwm.list, function (element) element$title)
101:   matrix.ids <- names(matrices)
103:   for (matrix.id in matrix.ids) {
302:   rawMatrixList <- readRawMatrices("./", dataDir)
44:   for (i in 1:max){ # loop through all motifs in the matrix file, one motif at a time
63:    mtx <- pwm.1$matrix
71: # rather than a sublist of title and matrix, each element is simply a matrix, with the element named
74:   matrices <- sapply(pwm.list, function (element) element$matrix)
76:   matrix.names <- sub("^> ", "", matrix.names)
77:   names(matrices) <- matrix.names
104:     tokens <- strsplit(matrix.id, ".", fixed=TRUE)[[1]]
107:     geneSymbol <- sub("_HUMAN.*$", "", matrix.id)
108:     tbl.sub <- subset(tbl.raw, Model==matrix.id)
116:     new.row <- list (providerName=matrix.id,
117:                      providerId=matrix.id, #"HOCOMOCO v8 and ChiPMunk 3.1"
125:                      sequenceCount=max(colSums(matrix)),
131:     #printf("matrix.id: %s", matrix.id);
134:     full.name <- sprintf ('%s-%s-%s', organism, dataSource, matrix.id)
136:     } # for matrix.id
151:      # make sure the reliability score (A-D) is searchably found in the matrix rowname
162: # we now have metadata rownames, one per matrix, each of which has all (or at least at lot) of information
163: # used in querying.  For instance, the hocomoco give name for the first matrix is
209:      # after normalization, each matrix column should total to 1.0
210:      # so sum(matrix) should be equals to the number of columns
232:   result <- matrix (nrow=4, ncol=cols,
247:   #return (list (title=title, consensus.sequence=consensus.sequence, matrix=result))
248:   return (list (title=title, matrix=result))
303:   length(rawMatrixList)
304:   matrices <- extractMatrices (rawMatrixList)
ELMER:R/Small.R: [ ]
903:   matrix <- Matrix::Matrix(0, nrow = nrow(motifs), ncol = ncol(motifs) - 21 ,sparse = TRUE)
363: makeSummarizedExperimentFromGeneMatrix <- function(exp, genome = genome){
476: splitmatrix <- function(x,by="row") {
900: getMatrix <- function(filename) {
5: #' @param met A Summaerized Experiment, a matrix or path of rda file only containing the data.
6: #' @param exp A Summaerized Experiment, a matrix or path of rda file only containing the data. Rownames should be 
11: #'  of the gene expression and DNA methylation matrix. This should be used if your matrix
14: ...(14 bytes skipped)...A methylation" and "Gene expression"), primary (sample ID) and colname (names of the columns of the matrix).
89: #'    #1) Get gene expression matrix
246:         stop("Please the gene expression matrix should receive ENSEMBLE IDs")
307:         stop("Error DNA methylation matrix and gene expression matrix are not in the same order")
322: ...(63 bytes skipped)...ary (sample ID) and colname(DNA methylation and gene expression sample [same as the colnames of the matrix])")
341:         stop("Error DNA methylation matrix and gene expression matrix are not in the same order")
387:     stop("Please the gene expression matrix should receive ENSEMBLE IDs (ENSG)")
409:   assay <- data.matrix(met)
442: #' This function will receive the DNA methylation and gene expression matrix and will create
444: #' @param met DNA methylation matrix or Summarized Experiment
445: #' @param exp Gene expression matrix or Summarized Experiment
473: # @param x A matrix 
475: # @return A list each of which is the value of each row/column in the matrix.
693: #' @param data A MultiAssayExperiment with a DNA methylation martrix or a DNA methylation matrix
896: # This will read this homer file and create a sparce matrix
904:   colnames(matrix) <- gsub(" Distance From Peak\\(sequence,strand,conservation\\)","",colnames(motifs)[-c(1:21)])
905:   rownames(matrix) <- motifs$PeakID
906:   matrix[!is.na(motifs[,-c(1:21)])] <- 1
907:   matrix <- as(matrix, "nsparseMatrix")
908:   return(matrix)
917: #' foreground <- Matrix::Matrix(sample(0:1,size = 100,replace = TRUE), 
921: #' background <- Matrix::Matrix(sample(0:1,size = 100,replace = TRUE), 
935:   a <- Matrix::colSums(foreground)
936:   b <- nrow(foreground) - Matrix::colSums(foreground)
937:   c <- Matrix::colSums(background)
938:   d <- nrow(background) - Matrix::colSums(background)
940:     x <- fisher.test(matrix(c(a[i],b[i],c[i],d[i]),nrow = 2,ncol = 2))
947:                         NumOfRegions = Matrix::colSums(foreground, na.rm=TRUE),
210:     exp <- makeSummarizedExperimentFromGeneMatrix(exp, genome)
913: #' @param foreground A nsparseMatrix object in each 1 means the motif is found in a region, 0 not.
914: #' @param background A nsparseMatrix object in each 1 means the motif is found in a region, 0 not.
interacCircos:inst/htmlwidgets/lib/d3.js: [ ]
5599:     chord.matrix = function(x) {
167:   d3.transpose = function(matrix) {
168:     return d3.zip.apply(d3, matrix);
5377:       return new d3_transform(t ? t.matrix : d3_transformIdentity);
5527:     var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
5536:           x += matrix[i][j];
5550:             return sortSubgroups(matrix[i][a], matrix[i][b]);
5559:           var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
5600:       if (!arguments.length) return matrix;
5601:       n = (matrix = x) && matrix.length;
1108:       point = point.matrixTransform(container.getScreenCTM().inverse());
GeneTonic:R/gs_heatmap.R: [ ]
209:       matrix = mydata_sig,
484:   score_matrix <- mat
265:       matrix = mydata_sig,
301: #' @return A matrix with the geneset Z scores, e.g. to be plotted with [gs_scoresheat()]
362:   # returns a matrix, rows = genesets, cols = samples
369:   gss_mat <- matrix(NA, nrow = nrow(res_enrich), ncol = ncol(se))
391: #' Plots a matrix of geneset scores
393: #' Plots a matrix of geneset Z scores, across all samples
395: #' @param mat A matrix, e.g. returned by the [gs_scores()] function
487:     score_matrix <- score_matrix[row_tree$order, ]
491:     score_matrix <- score_matrix[, col_tree$order]
494:   labels_rows <- factor(rownames(score_matrix),
495:     levels = rev(rownames(score_matrix))
498:   labels_cols <- factor(colnames(score_matrix),
499:     levels = colnames(score_matrix)
506:   scores <- data.frame(as.vector(score_matrix))
365:   rowsd_se <- matrixStats::rowSds(mydata)
IRISFGM:R/CellTypePrediction.R: [ ]
76:         MATRIX <- rep(0, Covered) %o% rep(0, Covered)
48: #' @importFrom igraph as_adjacency_matrix
61:     A <- igraph::as_adjacency_matrix(G, type = "both", attr = "Weight", names = TRUE, sparse = FALSE)  # convert graph into adjacency matrix
87:             MATRIX <- MATRIX + TEMP
89:         MATRIX <- MATRIX/length(CAN_I)
90:         rownames(MATRIX) <- colnames(MATRIX) <- rownames(A)
91:         hc <- hclust(dist(MATRIX))
117: #' @importFrom igraph as_adjacency_matrix
124:     A <- igraph::as_adjacency_matrix(G, type = "both", attr = "Weight", names = TRUE, sparse = FALSE)  # convert graph into adjacency matrix
141: ## Raw is the path to the original expression matrix method should be either 'MCL' or 'SC', and if 'SC', user also need to specify K, the number of
BioNERO:R/consensus_modules.R: [ ]
448:     hm <- WGCNA::labeledHeatmap(Matrix = cons_cor,
424:     textMatrix <- paste(signif(cons_cor, 2), modtraitsymbol, sep = "")
193:     if(verbose) { message("Calculating adjacency matrix...") }
210:     if(verbose) { message("Calculating topological overlap matrix (TOM)...") }
332: #' @param cex.text Font size for numbers inside matrix. Default: 0.6.
396:     cons_cor <- matrix(NA, nrow(moduleTraitCor[[1]]), ncol(moduleTraitCor[[1]]))
397:     cons_pval <- matrix(NA, nrow(moduleTraitCor[[1]]), ncol(moduleTraitCor[[1]]))
425:     textMatrix[textMatrix == "NANA"] <- "-"
426:     dim(textMatrix) <- dim(moduleTraitCor[[set]])
429:         textMatrix <- t(textMatrix)
453:                                 textMatrix = textMatrix, setStdMargins = FALSE,
MethReg:R/filter_by_quantile.R: [ ]
30:         matrix <- assay(dnam)
125:         matrix <- assay(exp)
182:         matrix <- assay(exp)
7: #' @param dnam DNA methylation matrix or SumarizedExperiment object
19: #' A subset of the original matrix only with the
32:         matrix <- dnam
36:     keep.rows <- which(rowSums(is.na(matrix)) != ncol(matrix))
37:     if(length(keep.rows) < nrow(matrix)){
39:         matrix <- matrix[keep.rows,]
42:     IQR <- calculate_IQR(matrix)
55:     matrix <- matrix[diff.regions,,drop = FALSE]
58:         dnam <- dnam[rownames(matrix),]
59:         assay(dnam) <- matrix
61:         dnam <- matrix
69: #'   matrix(nrow = 1,dimnames = list(c("row1"), LETTERS[1:10])) %>%
72: calculate_IQR <- function(matrix){
75:         "ID" = rownames(matrix),
76:         "IQR" = matrixStats::rowIQRs(matrix, na.rm = TRUE)
83: #'   matrix(nrow = 1,dimnames = list(c("row1"), LETTERS[1:10])) %>%
86: calculate_mean_q4_minus_mean_q1 <- function(matrix, cores = 1){
89:     plyr::adply(.data = matrix,.margins = 1,.fun = function(row){
102: #' @param exp Gene expression matrix or SumarizedExperiment object
116: #' A subset of the original matrix only with the rows passing
127:         matrix <- exp
132:     diff.genes <- plyr::adply(matrix,.margins = 1,.fun = function(row){
166: #' @param exp Gene expression matrix or SumarizedExperiment object
174: #' @return A subset of the original matrix only with the rows
184:         matrix <- exp
187:     na.or.zeros <- matrix == 0 | is.na(matrix)
188:     percent.na.or.zeros <- rowSums(na.or.zeros) / ncol(matrix)
191:     message("Removing ", nrow(matrix) - length(genes.keep), " out of ", nrow(matrix), " genes")
197: #' @param exp Gene expression matrix or a Summarized Experiment object
205: #' A subset of the original matrix only with the rows
73:     check_package("matrixStats")
M3C:R/clustersim.R: [ ]
37:   matrix = matrix(nrow = n, ncol = 3)
50:   matrix2 <- subset(data.frame(matrix), X3 < r)
108:   final_matrix <- as.matrix(final_df)
13: #' @return A list: containing 1) matrix with simulated data in it
38:   matrix[,1] <- rep(c(1:sqrt(n)),each=sqrt(n))
39:   matrix[,2] <- rep(c(1:sqrt(n)), sqrt(n))
42:   x1 <- (cluster::pam(data.frame(matrix)[,1:2], 1)$medoids)[1]
43:   y1 <- (cluster::pam(data.frame(matrix)[,1:2], 1)$medoids)[2]
45:   x2 <- matrix[,1]
46:   y2 <- matrix[,2]
48:   matrix[,3] <- answer
51:   #plot(matrix2[,1], matrix2[,2])
52:   matrix2[] <- vapply(as.matrix(matrix2), addnoise, numeric(1))
53:   #plot(matrix2[,1], matrix2[,2])
58:   res = matrix(nrow = nrow(matrix2), ncol = n2)
59:   for (i in seq(1,nrow(matrix2),1)){
60:     a <- matrix2[i,1] # get fixed co ordinate1 for entire row
61:     b <- matrix2[i,2] # get fixed co ordinate2 for entire row
72:   scores <- data.frame(pca1$x) # PC score matrix
104:   # convert back to a matrix of data for clustering
112:   jjj <- t(final_matrix[,4:5] %*% t(pca1$rotation[,1:2])) + pca1$center # equation, PCs * eigenvectors = original data
128:   scores <- data.frame(pca1$x) # PC score matrix
UMI4Cats:R/utils.R: [ ]
122:   matrix <- assay(umi4c)
130:   mat_sp <- lapply(ids, function(x) matrix[x,])
155:   dds <- DESeq2::DESeqDataSetFromMatrix(
motifmatchr:src/MOODS/scanner.h: [ ]
16:         std::size_t matrix;
37:         void set_motifs(const std::vector<score_matrix>& matrices,
XNAString:src/ViennaRNA/constraints/hard.h: [ ]
383:       unsigned char *matrix;     /**<  @brief  Upper triangular matrix that encodes where a
391:       unsigned char         **matrix_local;
352:  *  used in the folding recursions. Attribute 'matrix' is used as source for
354:  *  Any entry in matrix[i,j] consists of the 6 LSB that allows one to distinguish the
scRepertoire:R/combineContigs.R: [ ]
185:     matrix <- as.matrix(stringdistmatrix(tmp, method = "lv"))
186:     out_matrix <- matrix(ncol = ncol(matrix), nrow=ncol(matrix))
71:         Con.df <- data.frame(matrix(NA, length(unique_df), 7))
142:         Con.df <- data.frame(matrix(NA, length(unique_df), 9))
187:     for (j in seq_len(ncol(matrix))) {
188:         for (k in seq_len(nrow(matrix))) {
190:                 out_matrix[j,k] <- NA
193:                     out_matrix[j,k] <- matrix[j,k]/(max(length[j], length[k]))
194:                     out_matrix[k,j] <- matrix[k,j]/(max(length[j], length[k]))
196:                 out_matrix[j,k] <- matrix[j,k]/((length[j]+ length[k])/2)
197:                 out_matrix[k,j] <- matrix[k,j]/((length[j]+ length[k])/2)
202:     filtered <- which(out_matrix <= 0.15, arr.ind = TRUE)
177: #' @importFrom stringdist stringdistmatrix
NetSAM:R/mapToSymbol.R: [ ]
98:                     matrix <- mapresult$data_symbol
15:     if(length(which(inputType %in% c("genelist","network","sbt","sct","matrix")))==0){
16: ...(20 bytes skipped)...put 'inputType' is invalide! Please select an option from 'genelist', 'netwrok', 'sbt', 'sct', and 'matrix'!\n")
78:     if(inputType=="matrix"){
81:             outputFileName <- "matrix_symbol.cct"
88:                 stop("The ids in the input matrix can not be transformed to gene symbols! Please check whether the inut idType is correct!\n")
93:                     stop(paste("Only ",round(mapresult*100),"% ids in the input matrix can be transformed to gene symbols. Please check whether the inut idType is correct!\n",sep=""))
99:                     matrix <- cbind(rownames(matrix),matrix)
100:                     colnames(matrix)[1] <- "GeneSymbol"
101:                     write.table(matrix,file=outputFileName,row.names=F,col.names=T,sep="\t",quote=F)
430:         if(.getClass(inputNetwork)=="data.frame" || .getClass(inputNetwork)=="matrix"){
439:                         inputNetwork <- as.matrix(inputNetwork[,c(1,2)])
450:                     inputNetwork <- as.matrix(inputNetwork)
490: ...(0 bytes skipped)...                    stop("The input network should be from a file or a data object with data.frame, matrix, graphNEL or igraph class. Other types of input are invalid!\n")
650:     inputMat <- as.matrix(inputMat[,2:ncol(inputMat)])
667:             inputMat <- as.matrix(inputMat[idmap[,1],])
pcaMethods:R/pca.R: [ ]
122:     Matrix <- as.matrix(object[,num])
25: ##' Perform PCA on a numeric matrix for visualisation, information
53: ##' @param object Numerical matrix with (or an object coercible to
56: ##' matrix is used. Can also be a data frame in which case all
125:     Matrix <- t(exprs(object))
127:   Matrix <- as.matrix(object, rownames.force=TRUE)
130:     Matrix <- Matrix[,subset]
135:   if (nPcs > ncol(Matrix)) {
136:     warning("more components than matrix columns requested")
137:     nPcs <- min(dim(Matrix))
139:   if (nPcs > nrow(Matrix)) {
140:     warning("more components than matrix rows requested")
141:     nPcs <- min(dim(Matrix))
144:   if (!checkData(Matrix, verbose=interactive()))
148:   missing <- is.na(Matrix)
162:   prepres <- prep(Matrix, scale=scale, center=center, simple=FALSE, ...)
196:   rownames(res@scores) <- rownames(Matrix)
197:   if(all(dim(loadings(res)) == c(ncol(Matrix), nPcs))) {
199:     rownames(res@loadings) <- colnames(Matrix)
205:   res@nObs <- nrow(Matrix)
206:   res@nVar <- ncol(Matrix)
217:     cObs <- Matrix
219:       cObs[missing] <- fitted(res, Matrix, pre=TRUE, post=TRUE)[missing]
225:     res@cvstat <- Q2(res, Matrix, nruncv=1, ...)
236: ##' @param object Numerical matrix with (or an object coercible to
239: ##' matrix is used.
240: ##' @param method For convenience one can pass a large matrix but only
264:   if ( !checkData(as.matrix(object), verbose=interactive()) )
344: ##' @param Matrix Pre-processed (centered and possibly scaled)
345: ##' numerical matrix samples in rows and variables as columns. No
350: ##' @param verbose Verbose complaints to matrix structure
364: svdPca <- function(Matrix, nPcs=2, 
367:   pcs <- prcomp(Matrix, center=FALSE, scale.=FALSE)
396: ##' @return A matrix with X and Y coordinates for the circle
R4RNA:R/io.R: [ ]
86:     matrix <- data.frame(matrix(unlist(cells), ncol = 3, byrow = TRUE))    
87:     i <- as.integer(as.character(matrix[, 1]))
88:     j <- as.integer(as.character(matrix[, 3]))
90:     seq <- paste(matrix[1:width, 2], collapse = "")
canceR:R/geteSet.R: [ ]
82:                     matrix <-rbind.na(colnames(ClinicalData), ClinicalData)
115:                     getInTable(matrix,title)
135:                     AssayData <- as.matrix(apply(AssayData,2 ,function(x) as.numeric(x)))
169:                         #             pData(eSet)[i] <- as.matrix(na.omit(pData(eSet)[i]))
plotgardener:R/readHic.R: [ ]
445:             matrix = rhic$matrix
16: #'     matrix = "observed",
48: #' @param matrix Character value indicating the type of matrix to output.
49: #' Default value is \code{matrix = "observed"}. Options are:
84:                     zrange = NULL, norm = "KR", matrix = "observed",
426:         upper <- data.frame(matrix(nrow = 0, ncol = 3))
432:     if (rhic$matrix == "logoe") {
433:         rhic$matrix <- "oe"
snpStats:src/gsl_poly.h: [ ]
118:   double * matrix ; 
cisPath:inst/extdata/D3/d3.layout.js: [ ]
166:   chord.matrix = function(x) {
64:       matrix,
88:         x += matrix[i][j];
106:           return sortSubgroups(matrix[i][a], matrix[i][b]);
122:             v = matrix[di][dj],
167:     if (!arguments.length) return matrix;
168:     n = (matrix = x) && matrix.length;
pcxn:R/pcxn_explore.R: [ ]
61:             matrix <- pathCor_pathprint_v1.2.3_dframe 
150:     step1_matrix <- as.data.frame(rbind(m1,m2))
164:     step2_matrix <- subset(matrix, Pathway.A %in% interesting_genesets &
168:     step3_matrix <- subset(step2_matrix, abs(PathCor) >= min_abs_corr &
66:             matrix <- pathCor_pathprint_v1.2.3_unadjusted_dframe 
76:             matrix <- pathCor_Hv5.1_dframe
80:             matrix <- pathCor_Hv5.1_unadjusted_dframe 
97:             matrix <- pathCor_CPv5.1_dframe
101:             matrix <- pathCor_CPv5.1_unadjusted_dframe 
118:             matrix <- pathCor_GOBPv5.1_dframe
122:             matrix <- pathCor_GOBPv5.1_unadjusted_dframe 
148:     m1 <- subset(matrix,Pathway.A == query_geneset)
149:     m2 <- subset(matrix,Pathway.B == query_geneset)
151:     top_step1_matrix<- 
152:         (step1_matrix[order(-abs(step1_matrix$PathCor)),])[1:top,]
155:     interesting_genesets <- unique(as.list(c(top_step1_matrix$Pathway.A,
156:                                             top_step1_matrix$Pathway.B)))
158:     # create matrix with geneset groups
172:                 " top correlated genesets, ", dim(step3_matrix)[1],
175:     po = new("pcxn",type = "pcxn_explore", data = as.matrix(step3_matrix),
SICtools:src/kaln.h: [ ]
39: 	int *matrix;
47: 	int *matrix;
beachmat:inst/include/beachmat3/lin_matrix.h: [ ]
26: class lin_matrix {
31:     lin_matrix() {}
189: class lin_sparse_matrix : public lin_matrix {
194:     lin_sparse_matrix() {}
368: class lin_ordinary_matrix : public lin_matrix {
375:     lin_ordinary_matrix(Rcpp::RObject mat) : reader(mat) {
408: using integer_ordinary_matrix = lin_ordinary_matrix<Rcpp::IntegerVector>;
422: using logical_ordinary_matrix = lin_ordinary_matrix<Rcpp::LogicalVector>;
436: using double_ordinary_matrix = lin_ordinary_matrix<Rcpp::NumericVector>;
459: class gCMatrix : public lin_sparse_matrix {
466:     gCMatrix(Rcpp::RObject mat) : reader(mat) {
521: using lgCMatrix = gCMatrix<Rcpp::LogicalVector, const int*>;
533: using dgCMatrix = gCMatrix<Rcpp::NumericVector, const double*>;
2: #define BEACHMAT_LIN_MATRIX_H
1: #ifndef BEACHMAT_LIN_MATRIX_H
5:  * @file lin_matrix.h
7:  * Class definitions for the logical, integer or numeric (LIN) matrix.
21:  * @brief Virtual base class for a logical, integer or numeric (i.e., double-precision) matrix,
33:     virtual ~lin_matrix() = default;
34:     lin_matrix(const lin_matrix&) = default;
35:     lin_matrix& operator=(const lin_matrix&) = default;
36:     lin_matrix(lin_matrix&&) = default;
37:     lin_matrix& operator=(lin_matrix&&) = default;
49:      * This may or may not involve populating `work` with values copied from the underlying matrix;
78:      * This may or may not involve populating `work` with values copied from the underlying matrix;
105:      * This may or may not involve populating `work` with values copied from the underlying matrix;
134:      * This may or may not involve populating `work` with values copied from the underlying matrix;
156:      * Get the number of rows in the matrix.
161:      * Get the number of columns in the matrix.
166:      * Is the matrix sparse?
173:     std::unique_ptr<lin_matrix> clone() const {
174:         return std::unique_ptr<lin_matrix>(this->clone_internal());
180:     virtual lin_matrix* clone_internal() const = 0;
184:  * @brief Virtual base class for a sparse logical, integer or numeric (i.e., double-precision) matrix.
196:     ~lin_sparse_matrix() = default;
197:     lin_sparse_matrix(const lin_sparse_matrix&) = default;
198:     lin_sparse_matrix& operator=(const lin_sparse_matrix&) = default;
199:     lin_sparse_matrix(lin_sparse_matrix&&) = default;
200:     lin_sparse_matrix& operator=(lin_sparse_matrix&&) = default;
233:      * This may or may not involve populating `work` with values copied from the underlying matrix;
269:      * This may or may not involve populating `work` with values copied from the underlying matrix;
284:      * This may or may not involve populating `work` with values copied from the underlying matrix;
318:      * This may or may not involve populating `work` with values copied from the underlying matrix;
345:      * Get the number of non-zero elements in the matrix.
352:     std::unique_ptr<lin_sparse_matrix> clone() const {
353:         return std::unique_ptr<lin_sparse_matrix>(this->clone_internal());
356:     lin_sparse_matrix* clone_internal() const = 0;
371:      * Constructor from an ordinary R-level matrix.
373:      * @param mat An ordinary R matrix.
381:     ~lin_ordinary_matrix() = default;
382:     lin_ordinary_matrix(const lin_ordinary_matrix&) = default;
383:     lin_ordinary_matrix& operator=(const lin_ordinary_matrix&) = default;
384:     lin_ordinary_matrix(lin_ordinary_matrix&&) = default;
385:     lin_ordinary_matrix& operator=(lin_ordinary_matrix&&) = default;
403:     lin_ordinary_matrix<V>* clone_internal() const {
404:         return new lin_ordinary_matrix<V>(*this);
411: inline const int* integer_ordinary_matrix::get_col(size_t c, int* work, size_t first, size_t last) {
416: inline const double* integer_ordinary_matrix::get_col(size_t c, double* work, size_t first, size_t last) {
425: inline const int* logical_ordinary_matrix::get_col(size_t c, int* work, size_t first, size_t last) {
430: inline const double* logical_ordinary_matrix::get_col(size_t c, double* work, size_t first, size_t last) {
439: inline const int* double_ordinary_matrix::get_col(size_t c, int* work, size_t first, size_t last) {
446: inline const double* double_ordinary_matrix::get_col(size_t c, double* work, size_t first, size_t last) {
451:  * @brief Sparse logical or numeric matrices in the `lgCMatrix` or `dgCMatrix` format, respectively, from the **Matrix** package.
554: class lin_SparseArraySeed : public lin_sparse_matrix {
462:      * Constructor from a `*gCMatrix`.
464:      * @param mat A S4 object of the `dgCMatrix` or `lgCMatrix` class.
472:     ~gCMatrix() = default;
473:     gCMatrix(const gCMatrix&) = default;
474:     gCMatrix& operator=(const gCMatrix&) = default;
475:     gCMatrix(gCMatrix&&) = default;
476:     gCMatrix& operator=(gCMatrix&&) = default;
514:     gCMatrix_reader<V, TIT> reader;
516:     gCMatrix<V, TIT>* clone_internal() const {
517:         return new gCMatrix<V, TIT>(*this);
524: inline sparse_index<const int*, int> lgCMatrix::get_col(size_t c, int* work_x, int* work_i, size_t first, size_t last) {
529: inline sparse_index<const double*, int> lgCMatrix::get_col(size_t c, double* work_x, int* work_i, size_t first, size_t last) {
536: inline sparse_index<const int*, int> dgCMatrix::get_col(size_t c, int* work_x, int* work_i, size_t first, size_t last) {
541: inline sparse_index<const double*, int> dgCMatrix::get_col(size_t c, double* work_x, int* work_i, size_t first, size_t last) {
BufferedMatrix:src/doubleBufferedMatrix.c: [ ]
149: struct _double_buffered_matrix
204: } _double_buffered_matrix;
7:  ** aim: A class to represent a resizable matrix of doubles.
27:  **                 that work across the whole matrix eg colSums, colMin etc
52:  ** This is an abbreviation for "double buffered matrix"
54:  ** Basic Idea: Store a Matrix partially in memory.
60:  **            Assumption is that most access to matrix
78:  **            this means that if the matrix is being accessed across
101:  **            when data values are being READ from the matrix
103:  **            - check if it is in larger column matrix. If so return value
108:  **            when data values are being written into matrix
152:   int rows;  // number of rows in matrix
153:   int cols;  // number of cols in matrix
175:   int first_rowdata; /* matrix index of first row stored in rowdata  should be from 0 to rows */
217: static void dbm_SetClash(doubleBufferedMatrix Matrix,int row, int col);
218: static void dbm_ClearClash(doubleBufferedMatrix Matrix);
219: static int dbm_InRowBuffer(doubleBufferedMatrix Matrix,int row, int col);
220: static int dbm_InColBuffer(doubleBufferedMatrix Matrix,int row, int col,int *which_col_index);
222: static int dbm_FlushRowBuffer(doubleBufferedMatrix Matrix);
223: static int dbm_FlushOldestColumn(doubleBufferedMatrix Matrix);
224: static int dbm_FlushAllColumns(doubleBufferedMatrix Matrix);
226: static int dbm_LoadNewColumn(doubleBufferedMatrix Matrix,int col);
227: static int dbm_LoadRowBuffer(doubleBufferedMatrix Matrix,int row);
229: static int dbm_LoadAdditionalColumn(doubleBufferedMatrix Matrix,int col, int where);
231: static double *dbm_internalgetValue(doubleBufferedMatrix Matrix,int row, int col);
232: static int *dbm_whatsInColumnBuffer(doubleBufferedMatrix Matrix);
249:  ** void dbm_SetClash(doubleBufferedMatrix Matrix,int row, int col)
251:  ** doubleBufferedMatrix Matrix - a buffered Matrix object
252:  ** int row, col - location in matrix for potential clash
256:  ** and the location in the matrix of this clash.
266: static void dbm_SetClash(doubleBufferedMatrix Matrix,int row, int col){
267:   Matrix->rowcolclash = 1;
268:   Matrix->clash_row = row;
269:   Matrix->clash_col = col;
274:  ** void dbm_ClearClash(doubleBufferedMatrix Matrix)
276:  ** doubleBufferedMatrix Matrix - a buffered Matrix object
283: static void dbm_ClearClash(doubleBufferedMatrix Matrix){
291:   if (Matrix->cols < Matrix->max_cols){
292:     lastcol = Matrix->cols;
294:     lastcol = Matrix->max_cols;
298:     if (Matrix->which_cols[curcol] == Matrix->clash_col){
306:   if (Matrix->rowdata[Matrix->clash_col][Matrix->clash_row - Matrix->first_rowdata] != Matrix->coldata[curcol][Matrix->clash_row]){
308:     Matrix->coldata[curcol][Matrix->clash_row] = Matrix->rowdata[Matrix->clash_col][Matrix->clash_row - Matrix->first_rowdata];
311:   Matrix->rowcolclash=0;
319:  ** int dbm_InRowBuffer(doubleBufferedMatrix Matrix,int row, int col)
321:  ** doubleBufferedMatrix Matrix
322:  ** int row, int col - location in Matrix
329: static int dbm_InRowBuffer(doubleBufferedMatrix Matrix,int row, int col){
330:   if ((Matrix->first_rowdata <= row) && (row < Matrix->first_rowdata +  Matrix->max_rows)){
342:  ** int dbm_InColBuffer(doubleBufferedMatrix Matrix,int row, int col)
344:  ** doubleBufferedMatrix Matrix
345:  ** int row, int col - location in Matrix
352: static int dbm_InColBuffer(doubleBufferedMatrix Matrix,int row, int col, int *which_col_index){
355:   if (Matrix->cols < Matrix->max_cols){
356:     lastcol = Matrix->cols;
358:     lastcol = Matrix->max_cols;
364:     if (Matrix->which_cols[curcol] == col){
376:  ** int dbm_FlushRowBuffer(doubleBufferedMatrix Matrix)
378:  ** doubleBufferedMatrix Matrix
387: static int dbm_FlushRowBuffer(doubleBufferedMatrix Matrix){
397:   for (j =0; j < Matrix->cols; j++){
398:     myfile = fopen(Matrix->filenames[j],mode2);
402:     fseek(myfile,Matrix->first_rowdata*sizeof(double),SEEK_SET);
403:     blocks_written = fwrite(&(Matrix->rowdata)[j][0],sizeof(double),Matrix->max_rows,myfile);
405:     if (blocks_written != Matrix->max_rows){
414:  ** int dbm_FlushOldestColumn(doubleBufferedMatrix Matrix)
416:  ** doubleBufferedMatrix Matrix
426: static int dbm_FlushOldestColumn(doubleBufferedMatrix Matrix){
433:   myfile = fopen(Matrix->filenames[Matrix->which_cols[0]],mode2);
440:   blocks_written = fwrite(Matrix->coldata[0],sizeof(double),Matrix->rows,myfile);
442:   if (blocks_written != Matrix->rows){
453:  ** int dbm_FlushOldestColumn(doubleBufferedMatrix Matrix)
455:  ** doubleBufferedMatrix Matrix
467: static int dbm_FlushAllColumns(doubleBufferedMatrix Matrix){
478:   if (Matrix->cols < Matrix->max_cols){
479:     lastcol = Matrix->cols;
481:     lastcol = Matrix->max_cols;
486:     myfile = fopen(Matrix->filenames[Matrix->which_cols[k]],mode2);
491:     blocks_written = fwrite(Matrix->coldata[k],sizeof(double),Matrix->rows,myfile);
493:     if (blocks_written != Matrix->rows){
506:  ** void dbm_LoadNewColumn(doubleBufferedMatrix Matrix,int col);
508:  ** doubleBufferedMatrix Matrix
509:  ** int col - column of the matrix to load into the buffer
520: static int dbm_LoadNewColumn(doubleBufferedMatrix Matrix,int col){
529:   if (Matrix->cols < Matrix->max_cols){
530:     lastcol = Matrix->cols;
532:     lastcol = Matrix->max_cols;
535:   tmpptr = Matrix->coldata[0];
538:     Matrix->coldata[j-1] = Matrix->coldata[j];
539:     Matrix->which_cols[j-1] = Matrix->which_cols[j];
542:   Matrix->which_cols[lastcol -1] = col;
543:   Matrix->coldata[lastcol -1] = tmpptr;
546:   myfile = fopen(Matrix->filenames[col],mode);
551:   blocks_read = fread(Matrix->coldata[lastcol -1],sizeof(double),Matrix->rows,myfile);
554:   if (blocks_read != Matrix->rows){
565:  ** void dbm_LoadNewColumn_nofill(doubleBufferedMatrix Matrix,int col);
567:  ** doubleBufferedMatrix Matrix
568:  ** int col - column of the matrix to load into the buffer
583: static int dbm_LoadNewColumn_nofill(doubleBufferedMatrix Matrix,int col){
590:   if (Matrix->cols < Matrix->max_cols){
591:     lastcol = Matrix->cols;
593:     lastcol = Matrix->max_cols;
596:   tmpptr = Matrix->coldata[0];
599:     Matrix->coldata[j-1] = Matrix->coldata[j];
600:     Matrix->which_cols[j-1] = Matrix->which_cols[j];
603:   Matrix->which_cols[lastcol -1] = col;
604:   Matrix->coldata[lastcol -1] = tmpptr;
615:  ** int dbm_LoadRowBuffer(doubleBufferedMatrix Matrix,int row)
617:  ** doubleBufferedMatrix Matrix
630: static int dbm_LoadRowBuffer(doubleBufferedMatrix Matrix,int row){
642:   if (Matrix->cols < Matrix->max_cols){
643:     lastcol = Matrix->cols;
645:     lastcol = Matrix->max_cols;
648:   if (row > Matrix->rows - Matrix->max_rows){
649:     Matrix->first_rowdata = Matrix->rows - Matrix->max_rows;
651:     Matrix->first_rowdata = row;
654:   for (j =0; j < Matrix->cols; j++){
656:     myfile = fopen(Matrix->filenames[j],mode);
662:     fseek(myfile,Matrix->first_rowdata*sizeof(double),SEEK_SET);
663:     blocks_read = fread(&(Matrix->rowdata)[j][0],sizeof(double),Matrix->max_rows,myfile);
667:     if (blocks_read != Matrix->max_rows){
673:   for (j =0; j < Matrix->cols; j++){
676:       if (Matrix->which_cols[curcol] == j){
677: 	for (k= Matrix->first_rowdata; k < Matrix->first_rowdata + Matrix->max_rows; k++){
678: 	  Matrix->rowdata[j][k- Matrix->first_rowdata] = Matrix->coldata[curcol][k];
696:  ** int dbm_LoadAdditionalColumn(doubleBufferedMatrix Matrix,int col, int where)
698:  ** doubleBufferedMatrix Matrix
709: static int dbm_LoadAdditionalColumn(doubleBufferedMatrix Matrix,int col, int where){
714:   Matrix->coldata[where] = Calloc(Matrix->rows,double);
715:   Matrix->which_cols[where] = col;
716:   myfile = fopen(Matrix->filenames[col],mode);
720:   blocks_read = fread(Matrix->coldata[where],sizeof(double),Matrix->rows,myfile);
723:   if (blocks_read != Matrix->rows)
732:  ** double *dbm_internalgetValue(doubleBufferedMatrix Matrix,int row, int col)
736:  ** of element located at (row,col) in the matrix. Carries out all the necessary
741: static double *dbm_internalgetValue(doubleBufferedMatrix Matrix,int row, int col){
750:   if (!(Matrix->colmode)){
752:     if ((Matrix->rowcolclash)){
753:       dbm_ClearClash(Matrix);
758:     if (dbm_InRowBuffer(Matrix,whichrow,whichcol)){
760:       if (dbm_InColBuffer(Matrix,whichrow,whichcol,&curcol)){
761: 	dbm_SetClash(Matrix, whichrow,whichcol);
764:       return &(Matrix->rowdata[whichcol][whichrow - Matrix->first_rowdata]);
765:     } else if (dbm_InColBuffer(Matrix,whichrow,whichcol,&curcol)){
766:       return &(Matrix->coldata[curcol][whichrow]);
772:       if (!(Matrix->readonly)){
775: 	dbm_FlushRowBuffer(Matrix);
778: 	dbm_FlushOldestColumn(Matrix);
783:       dbm_LoadRowBuffer(Matrix,whichrow);
786:       dbm_LoadNewColumn(Matrix,whichcol);
789:       dbm_SetClash(Matrix,whichrow,whichcol);
790:       return &(Matrix->rowdata[whichcol][whichrow - Matrix->first_rowdata]);
794:     if (dbm_InColBuffer(Matrix,whichrow,whichcol,&curcol)){
795:       return &(Matrix->coldata[curcol][whichrow]);
797:       if (!(Matrix->readonly))
798: 	dbm_FlushOldestColumn(Matrix); 
799:       dbm_LoadNewColumn(Matrix,whichcol);
800:       return &(Matrix->coldata[Matrix->max_cols -1][whichrow]);
811:  ** static int *dbm_whatsInColumnBuffer(doubleBufferedMatrix Matrix)
819: static int *dbm_whatsInColumnBuffer(doubleBufferedMatrix Matrix){
821:   return Matrix->which_cols;
870:   struct _double_buffered_matrix *handle;
873:   handle = (struct _double_buffered_matrix *)Calloc(1,struct _double_buffered_matrix);
914:  ** int dbm_free(doubleBufferedMatrix Matrix)
916:  ** doubleBufferedMatrix *Matrix 
922: int dbm_free(doubleBufferedMatrix Matrix){
926:   struct _double_buffered_matrix *handle;
928:   handle = Matrix;
972:  ** int dbm_setRows(doubleBufferedMatrix Matrix, int Rows)
974:  ** doubleBufferedMatrix Matrix
975:  ** int Rows - number of rows in each column of the matrix
980:  ** the matrix. Once set the number of rows can not be altered.
985: int dbm_setRows(doubleBufferedMatrix Matrix, int Rows){
988:   if (Matrix->rows > 0){
992:   Matrix->rows = Rows;
994:   if (Matrix->rows < Matrix->max_rows){
995:     Matrix->max_rows = Matrix->rows;
1005:  ** int dbm_AddColumn(doubleBufferedMatrix Matrix)
1007:  ** doubleBufferedMatrix Matrix
1009:  ** Adds an additional column to the matrix at edge of 
1010:  ** Matrix. Note this entails creating an additional 
1012:  ** in the matrix should have already been set by 
1020: int dbm_AddColumn(doubleBufferedMatrix Matrix){
1030:   if (Matrix->cols < Matrix->max_cols){
1032:     int *temp_indices = Calloc(Matrix->cols+1, int);
1033:     int *temp_old_indices = Matrix->which_cols;
1034:     double **temp_ptr = Calloc(Matrix->cols +1,double *);
1035:     double **old_temp_ptr = Matrix->coldata;
1037:     for (j =0; j < Matrix->cols; j++){
1038:       temp_indices[j] = Matrix->which_cols[j];
1039:       temp_ptr[j] = Matrix->coldata[j];
1041:     temp_indices[Matrix->cols] =Matrix->cols;
1042:     temp_ptr[Matrix->cols] = Calloc(Matrix->rows,double);
1044:     Matrix->coldata = temp_ptr;
1046:     /* for (i =0; i < Matrix->rows; i++){
1047:        Matrix->coldata[Matrix->cols][i] = 0.0;  //(cols)*rows + i; 
1049:     memset(&Matrix->coldata[Matrix->cols][0],0,sizeof(double)* Matrix->rows);
1053:     which_col_num = Matrix->cols;
1054:     Matrix->which_cols = temp_indices;
1058:     if (!(Matrix->colmode)){
1060:       old_temp_ptr = Matrix->rowdata;
1061:       temp_ptr = Calloc(Matrix->cols+1,double *);
1063:       for (j =0; j <  Matrix->cols; j++){
1064: 	temp_ptr[j] =  Matrix->rowdata[j];
1066:       temp_ptr[Matrix->cols] = Calloc(Matrix->max_rows,double);
1068:       /* for (i=0; i < Matrix->max_rows; i++){
1069: 	 temp_ptr[Matrix->cols][i] = 0.0;   // (cols)*rows + i; 
1072:       memset(&temp_ptr[Matrix->cols][0],0,sizeof(double)* Matrix->max_rows);
1076:       Matrix->rowdata = temp_ptr;
1083:     double *temp_col = Matrix->coldata[0];
1084:     double **old_temp_ptr = Matrix->rowdata;
1087:     myfile = fopen(Matrix->filenames[Matrix->which_cols[0]],"rb+");
1088:     blocks_written = fwrite(&temp_col[0],sizeof(double),Matrix->rows,myfile);
1091:     if (blocks_written != Matrix->rows){
1096:     for (j =1; j < Matrix->max_cols; j++){
1097:       Matrix->which_cols[j-1] = Matrix->which_cols[j];
1098:       Matrix->coldata[j-1] = Matrix->coldata[j];
1100:     Matrix->which_cols[Matrix->max_cols-1] = Matrix->cols;
1101:     Matrix->coldata[Matrix->max_cols-1] = temp_col; //new double[this->rows];
1103:        for (i =0; i < Matrix->rows; i++){
1104:        Matrix->coldata[Matrix->max_cols-1][i] = 0.0; // (cols)*rows +i;
1107:     memset(&Matrix->coldata[Matrix->max_cols-1][0],0,sizeof(double)* Matrix->rows);
1110:     which_col_num = Matrix->max_cols-1;
1114:     if (!(Matrix->colmode)){
1115:       old_temp_ptr = Matrix->rowdata;
1116:       temp_ptr = Calloc(Matrix->cols+1,double *);
1118:       for (j =0; j < Matrix->cols; j++){
1119: 	temp_ptr[j] = Matrix->rowdata[j];
1121:       temp_ptr[Matrix->cols] = Calloc(Matrix->max_rows,double);
1124: 	for (i=0; i < Matrix->max_rows; i++){
1125: 	temp_ptr[Matrix->cols][i] = 0.0;      //(cols)*rows + i;
1128:       memset(&temp_ptr[Matrix->cols][0],0,sizeof(double)* Matrix->max_rows);
1130:       Matrix->rowdata = temp_ptr;
1138:   char **temp_filenames = Calloc(Matrix->cols+1,char *);
1140:   char **temp_names_ptr = Matrix->filenames;
1143:   for (j =0; j < Matrix->cols; j++){
1144:     temp_filenames[j] = Matrix->filenames[j];
1149:   temp_name = (char *)R_tmpnam(Matrix->fileprefix,Matrix->filedirectory);
1154:   temp_filenames[Matrix->cols] = Calloc(strlen(tmp)+1,char);
1155:   temp_filenames[Matrix->cols] = strcpy(temp_filenames[Matrix->cols],tmp);
1157:   Matrix->filenames = temp_filenames;
1168:   myfile = fopen(temp_filenames[Matrix->cols],mode);
1172:   blocks_written = fwrite(Matrix->coldata[which_col_num],sizeof(double),  Matrix->rows, myfile);
1174:   if (blocks_written != Matrix->rows){
1179:   Matrix->cols++;
1187:  ** int dbm_ResizeColBuffer(doubleBufferedMatrix Matrix, int new_maxcol)
1189:  ** doubleBufferedMatrix Matrix
1200: int dbm_ResizeColBuffer(doubleBufferedMatrix Matrix, int new_maxcol){
1218:   if (Matrix->rowcolclash){
1219:     dbm_ClearClash(Matrix);
1227:   if (Matrix->cols < Matrix->max_cols){
1228:     lastcol = Matrix->cols;
1230:     lastcol = Matrix->max_cols;
1234:   if (Matrix->max_cols == new_maxcol){
1237:   } else if (Matrix->max_cols > new_maxcol){
1240:     if (new_maxcol < Matrix->cols){
1241:       if (Matrix->max_cols < Matrix->cols){
1242: 	n_cols_remove = Matrix->max_cols - new_maxcol;
1244: 	n_cols_remove = Matrix->cols - new_maxcol;
1249: 	dbm_FlushOldestColumn(Matrix);
1250: 	tmpptr = Matrix->coldata[0];
1252: 	  Matrix->coldata[j-1] = Matrix->coldata[j];
1253: 	  Matrix->which_cols[j-1] = Matrix->which_cols[j];
1258:       tmpptr2 = Matrix->coldata;
1259:       tmpptr3 = Matrix->which_cols;
1261:       Matrix->coldata = Calloc(new_maxcol,double *);
1262:       Matrix->which_cols = Calloc(new_maxcol,int);
1265: 	Matrix->coldata[j] = tmpptr2[j];
1266: 	Matrix->which_cols[j] = tmpptr3[j];
1271:     Matrix->max_cols = new_maxcol;
1276:     if (new_maxcol < Matrix->cols){
1277:       n_cols_add = new_maxcol - Matrix->max_cols;
1278:     } else if (Matrix->max_cols < Matrix->cols){
1279:       n_cols_add = Matrix->cols - Matrix->max_cols;
1283:       Matrix->max_cols = new_maxcol;
1294:       for (j=min_j; j < Matrix->cols; j++){ /************************** *****/
1296: 	if(!dbm_InColBuffer(Matrix,0,j,&curcol)){
1306:     tmpptr2 = Matrix->coldata;
1307:     tmpptr3 = Matrix->which_cols;
1309:     Matrix->coldata = Calloc(Matrix->max_cols+ n_cols_add, double *);
1310:     Matrix->which_cols = Calloc(new_maxcol+ n_cols_add,int);  
1311:     for (j=0; j < Matrix->max_cols; j++){
1312:       Matrix->coldata[j] = tmpptr2[j];
1313:       Matrix->which_cols[j] = tmpptr3[j];
1317:       dbm_LoadAdditionalColumn(Matrix,whichadd[i], Matrix->max_cols + i);
1323:     Matrix->max_cols = new_maxcol;
1332:  ** int dbm_ResizeRowBuffer(doubleBufferedMatrix Matrix, int new_maxrow)
1334:  ** doubleBufferedMatrix Matrix
1346: int dbm_ResizeRowBuffer(doubleBufferedMatrix Matrix, int new_maxrow){
1363:   if (new_maxrow > Matrix->rows){
1364:     new_maxrow = Matrix->rows;
1367:   if (Matrix->colmode){
1368:     Matrix->max_rows =new_maxrow;
1374:   if (Matrix->rowcolclash){
1375:     dbm_ClearClash(Matrix);
1378:   if (Matrix->max_rows == new_maxrow){
1381:   } else if (Matrix->max_rows > new_maxrow){
1384:     dbm_FlushRowBuffer(Matrix);
1386:     for (j =0; j < Matrix->cols; j++){
1388:       tmpptr = Matrix->rowdata[j];
1389:       Matrix->rowdata[j] = Calloc(new_maxrow,double);
1391: 	 Matrix->rowdata[j][i] = tmpptr[i];
1395:     Matrix->max_rows = new_maxrow;
1400:     dbm_FlushRowBuffer(Matrix);
1404:     for (j =0; j < Matrix->cols; j++){ 
1405:       tmpptr = Matrix->rowdata[j];
1406:       Matrix->rowdata[j] = Calloc(new_maxrow,double);
1411:     // Now see if we will be hitting the bottom of the matrix with the added rows
1413:     if (Matrix->first_rowdata + new_maxrow > Matrix->rows){
1414:       new_first_rowdata = Matrix->rows - new_maxrow;
1416:       new_first_rowdata = Matrix->rows;
1418:     Matrix->max_rows = new_maxrow;
1419:     dbm_LoadRowBuffer(Matrix,new_first_rowdata);
1430:  ** int dbm_ResizeBuffer(doubleBufferedMatrix Matrix, int new_maxrow,int new_maxcol)
1432:  ** doubleBufferedMatrix Matrix
1443: int dbm_ResizeBuffer(doubleBufferedMatrix Matrix, int new_maxrow, int new_maxcol){
1445:   dbm_ResizeColBuffer(Matrix,new_maxcol);
1446:   if (!(Matrix->colmode)){
1447:     dbm_ResizeRowBuffer(Matrix,new_maxrow);
1455:       Matrix->max_rows = 1;
1456:     } else if (new_maxrow > Matrix->rows){
1457:       Matrix->max_rows = Matrix->rows;
1459:       Matrix->max_rows = new_maxrow;
1468:  ** void dbm_RowMode(doubleBufferedMatrix Matrix)
1476: void dbm_RowMode(doubleBufferedMatrix Matrix){
1486:   if (Matrix->colmode == 1){
1487:     Matrix->rowdata = Calloc(Matrix->cols +1,double *);
1488:     for (j =0; j < Matrix->cols; j++){
1489:       Matrix->rowdata[j] = Calloc(Matrix->max_rows,double);
1491:     dbm_LoadRowBuffer(Matrix,0); /* this both fills the row buffer and copys across anything in the current column buffer */
1492:     Matrix->colmode =0;
1500:  ** void dbm_ColMode(doubleBufferedMatrix Matrix)
1506: void dbm_ColMode(doubleBufferedMatrix Matrix){
1515:   if (Matrix->colmode == 0){
1516:     if (Matrix->rowcolclash){
1517:       dbm_ClearClash(Matrix);
1519:     dbm_FlushRowBuffer(Matrix);
1521:     for (j =0; j < Matrix->cols; j++){
1522:       Free(Matrix->rowdata[j]);
1524:     Free(Matrix->rowdata);
1525:     Matrix->colmode = 1;
1532:  ** void dbm_SetPrefix(doubleBufferedMatrix Matrix,const char *prefix)
1535:  ** used for storing matrix.
1541: void dbm_SetPrefix(doubleBufferedMatrix Matrix,const char *prefix){
1548:   if (Matrix->fileprefix != NULL){
1549:     Free(Matrix->fileprefix);
1551:   Matrix->fileprefix = tmp;
1558:  ** void dbm_ReadOnlyMode(doubleBufferedMatrix Matrix, int setting)
1566: void dbm_ReadOnlyMode(doubleBufferedMatrix Matrix, int setting){
1580:   if (!(Matrix->readonly) & setting){
1581:     if (!(Matrix->colmode)){
1582:       if (Matrix->rowcolclash){
1583: 	dbm_ClearClash(Matrix);
1585:       dbm_FlushRowBuffer(Matrix);
1587:     dbm_FlushAllColumns(Matrix);
1592:   Matrix->readonly = setting;
1598:  ** int dbm_isReadOnlyMode(doubleBufferedMatrix Matrix)
1600:  ** doubleBufferedMatrix Matrix
1607: int dbm_isReadOnlyMode(doubleBufferedMatrix Matrix){
1609:   return (Matrix->readonly);
1615:  ** int dbm_isRowMode(doubleBufferedMatrix Matrix)
1617:  ** doubleBufferedMatrix Matrix
1624: int dbm_isRowMode(doubleBufferedMatrix Matrix){
1626:   return (!(Matrix->colmode));
1632:  ** int dbm_getValue(doubleBufferedMatrix Matrix, int row, int col, double *value)
1634:  ** doubleBufferedMatrix Matrix
1635:  ** int row, col - location in matrix
1636:  ** double *value - location to store value found in matrix
1643: int dbm_getValue(doubleBufferedMatrix Matrix, int row, int col, double *value){
1647:   if ((row >= Matrix->rows) || (col >= Matrix->cols) || (row < 0) || (col < 0)){
1652:   tmp = dbm_internalgetValue(Matrix,row,col);
1656:   if (!Matrix->colmode && Matrix->readonly){
1657:     Matrix->rowcolclash = 0;  /* If readonly. No need to worry about clashes */
1667:  ** int dbm_setValue(doubleBufferedMatrix Matrix, int row, int col, double value)
1669:  ** doubleBufferedMatrix Matrix
1670:  ** int row, col - location in matrix
1671:  ** double value - value to store in matrix
1676: int dbm_setValue(doubleBufferedMatrix Matrix, int row, int col, double value){
1679:   if (Matrix->readonly){
1683:     if ((row >= Matrix->rows) || (col >= Matrix->cols) || (row < 0) || (col < 0)){
1687:     tmp = dbm_internalgetValue(Matrix,row,col);
1696:  ** int dbm_getValueSI(doubleBufferedMatrix Matrix, int index, double *value)
1698:  ** doubleBufferedMatrix Matrix
1699:  ** int index - location in matrix
1700:  ** double *value - location to store value found in matrix
1703:  ** value in the matrix. copys this value into location of supplied
1712: int dbm_getValueSI(doubleBufferedMatrix Matrix, int index, double *value){
1714:   int whichcol = index/Matrix->rows;
1715:   int whichrow = index % Matrix->rows;
1717:   if ((whichcol >= Matrix->cols) || (whichrow >= Matrix->rows) || (whichrow < 0) || (whichcol < 0)){
1721:   tmp = dbm_internalgetValue(Matrix,whichrow,whichcol);
1725:   if (!Matrix->colmode && Matrix->readonly){
1726:     Matrix->rowcolclash = 0;  /* If readonly. No need to worry about clashes */
1735:  ** int dbm_setValueSI(doubleBufferedMatrix Matrix, int index, double value)
1737:  ** doubleBufferedMatrix Matrix
1738:  ** int index - location in matrix
1739:  ** double *value - location to store value found in matrix
1742:  ** value in the matrix. Sets value. 
1748: int dbm_setValueSI(doubleBufferedMatrix Matrix, int index, double value){
1750:   int whichcol = index/Matrix->rows;
1751:   int whichrow = index % Matrix->rows;
1753:   if (Matrix->readonly){
1758:     if ((whichcol >= Matrix->cols) || (whichrow >= Matrix->rows) || (whichrow < 0) || (whichcol < 0)){
1762:     tmp = dbm_internalgetValue(Matrix,whichrow,whichcol);
1772:  ** int dbm_getRowss(doubleBufferedMatrix Matrix)
1774:  ** returns the number of rows in the matrix 
1780: int dbm_getRows(doubleBufferedMatrix Matrix){
1781:   return(Matrix->rows);
1787:  ** int dbm_getCols(doubleBufferedMatrix Matrix)
1789:  ** doubleBufferedMatrix Matrix
1791:  ** returns the number of columns in the matrix 
1797: int dbm_getCols(doubleBufferedMatrix Matrix){
1798:   /* returns how many cols are currently in matrix */
1799:   return(Matrix->cols);
1805:  ** int dbm_getBufferCols(doubleBufferedMatrix Matrix)
1807:  ** doubleBufferedMatrix Matrix
1816: int dbm_getBufferCols(doubleBufferedMatrix Matrix){
1819:   return(Matrix->max_cols);
1825:  ** int dbm_getBufferRows(doubleBufferedMatrix Matrix)
1827:  ** doubleBufferedMatrix Matrix
1837: int dbm_getBufferRows(doubleBufferedMatrix Matrix){
1840:   return(Matrix->max_rows);
1851:  ** int dbm_getColumnValue(doubleBufferedMatrix Matrix, int *cols, double *value, int ncol)
1853:  ** doubleBufferedMatrix Matrix
1854:  ** int *col - locations in matrix
1855:  ** double *value - location to store value found in matrix (should have enough
1864: int dbm_getValueColumn(doubleBufferedMatrix Matrix, int *cols, double *value, int ncols){
1873:     if ((cols[j] >= Matrix->cols) || (cols[j] < 0)){
1878:   if (!Matrix->colmode){
1880:       for (i =0; i < Matrix->rows; i++){
1881: 	tmp = dbm_internalgetValue(Matrix,i,cols[j]);
1882: 	value[j*Matrix->rows+ i] = *tmp; 
1883: 	Matrix->rowcolclash = 0; /* we are not setting anything here */
1889:       if (dbm_InColBuffer(Matrix,0,cols[j],&curcol)){
1890: 	memcpy(&value[j*Matrix->rows],&(Matrix->coldata[curcol][0]),Matrix->rows*sizeof(double));
1892: 	if (!(Matrix->readonly))
1893: 	  dbm_FlushOldestColumn(Matrix); 
1894: 	dbm_LoadNewColumn(Matrix,cols[j]);
1895: 	memcpy(&value[j*Matrix->rows],&(Matrix->coldata[Matrix->max_cols -1][0]),Matrix->rows*sizeof(double));
1906: int dbm_getValueRow(doubleBufferedMatrix Matrix, int *rows, double *value, int nrows){
1916:     if ((rows[i] >= Matrix->rows) || (rows[i] < 0)){
1921:   if (Matrix->colmode){
1922:     if (Matrix->cols > Matrix->max_cols){ 
1926:      BufferContents= dbm_whatsInColumnBuffer(Matrix); 
1927:      colsdone = Calloc(Matrix->cols,int);
1929:      for (j=0; j < Matrix->max_cols; j++){
1931: 	 tmp = dbm_internalgetValue(Matrix,rows[i],BufferContents[j]);
1933: 	 Matrix->rowcolclash = 0; /* we are not setting anything here */
1940:      for (j=0; j < Matrix->cols; j++){
1943: 	   tmp = dbm_internalgetValue(Matrix,rows[i],j);
1945: 	   Matrix->rowcolclash = 0; /* we are not setting anything here */
1953:      for (j =0; j < Matrix->cols; j++){
1955: 	 tmp = dbm_internalgetValue(Matrix,rows[i],j);
1957: 	 Matrix->rowcolclash = 0; /* we are not setting anything here */
1963:       for (j =0; j < Matrix->cols; j++){
1964: 	tmp = dbm_internalgetValue(Matrix,rows[i],j);
1966: 	Matrix->rowcolclash = 0; /* we are not setting anything here */
1979: int dbm_setValueColumn(doubleBufferedMatrix Matrix, int *cols, double *value, int ncols){
1986:   if (Matrix->readonly){
1992:     if ((cols[j] >= Matrix->cols) || (cols[j] < 0)){
1996:   if (!Matrix->colmode){
1998:       for (i =0; i < Matrix->rows; i++){
1999: 	tmp = dbm_internalgetValue(Matrix,i,cols[j]);
2000: 	*tmp = value[j*Matrix->rows + i];
2005:       if (dbm_InColBuffer(Matrix,0,cols[j],&curcol)){
2006: 	memcpy(&(Matrix->coldata[curcol][0]),&value[j*Matrix->rows],Matrix->rows*sizeof(double));
2008: 	if (!(Matrix->readonly))
2009: 	  dbm_FlushOldestColumn(Matrix); 
2010: 	dbm_LoadNewColumn_nofill(Matrix,cols[j]);
2011: 	memcpy(&(Matrix->coldata[Matrix->max_cols -1][0]),&value[j*Matrix->rows],Matrix->rows*sizeof(double));
2030: int dbm_setValueRow(doubleBufferedMatrix Matrix, int *rows, double *value, int nrows){
2040:   if (Matrix->readonly){
2046:     if ((rows[i] >= Matrix->rows) || (rows[i] < 0)){
2052:   if (Matrix->colmode){
2053:     if (Matrix->cols > Matrix->max_cols){ 
2057:      BufferContents= dbm_whatsInColumnBuffer(Matrix); 
2058:      colsdone = Calloc(Matrix->cols,int);
2060:      for (j=0; j < Matrix->max_cols; j++){
2062: 	 tmp = dbm_internalgetValue(Matrix,rows[i],BufferContents[j]);
2070:      for (j=0; j < Matrix->cols; j++){
2073: 	   tmp = dbm_internalgetValue(Matrix,rows[i],j);
2081:       for (j =0; j < Matrix->cols; j++){  
2083: 	  tmp = dbm_internalgetValue(Matrix,rows[i],j);
2090:       for (j =0; j < Matrix->cols; j++){
2091: 	tmp = dbm_internalgetValue(Matrix,rows[i],j);
2105: char *dbm_getPrefix(doubleBufferedMatrix Matrix){
2108:   int len= strlen(Matrix->fileprefix);
2112:   strcpy(returnvalue,Matrix->fileprefix);
2119: char *dbm_getDirectory(doubleBufferedMatrix Matrix){
2122:   int len = strlen(Matrix->filedirectory);
2126:   strcpy(returnvalue,Matrix->filedirectory);
2133: char *dbm_getFileName(doubleBufferedMatrix Matrix, int col){
2136:   int len = strlen(Matrix->filenames[col]);
2140:   strcpy(returnvalue,Matrix->filenames[col]);
2153: int dbm_setNewDirectory(doubleBufferedMatrix Matrix, const char *newdirectory){
2167:   olddirectory = Matrix->filedirectory;
2169:   for (i =0; i < Matrix->cols; i++){
2170:     temp_name = (char *)R_tmpnam(Matrix->fileprefix,newdirectory);
2173:     rename(Matrix->filenames[i], tmp);
2174:     Matrix->filenames[i] = tmp;
2178:   Matrix->filedirectory = directory;
2194: int dbm_copyValues(doubleBufferedMatrix Matrix_target,doubleBufferedMatrix Matrix_source){
2200:   if ((Matrix_source->rows != Matrix_target->rows) || (Matrix_source->cols != Matrix_target->cols)){
2205:   for (j=0; j < Matrix_source->cols; j++){
2206:     for (i=0; i < Matrix_source->rows; i++){
2207:       value = dbm_internalgetValue(Matrix_source,i,j);
2208:       tmp = dbm_internalgetValue(Matrix_target,i,j);
2219: int dbm_ewApply(doubleBufferedMatrix Matrix,double (* fn)(double, double *),double *fn_param){
2230:   if (Matrix->cols > Matrix->max_cols){  
2232:     BufferContents= dbm_whatsInColumnBuffer(Matrix);
2233:     colsdone = Calloc(Matrix->cols,int);
2235:     /* Matrix doesn't have all the columns in the buffer */
2237:     for (j=0; j < Matrix->max_cols; j++){
2238:       for (i=0; i < Matrix->rows; i++){
2239: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2246:     for (j=0; j < Matrix->cols; j++){
2248: 	for (i=0; i < Matrix->rows; i++){
2249: 	  value = dbm_internalgetValue(Matrix,i,j);
2259:     for (j=0; j < Matrix->cols; j++){
2260:       for (i=0; i < Matrix->rows; i++){
2261: 	value = dbm_internalgetValue(Matrix,i,j);
2277: double dbm_max(doubleBufferedMatrix Matrix,int naflag, int *foundfinite){
2288:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2290:   colsdone = Calloc(Matrix->cols,int);
2295:   if (Matrix->cols > Matrix->max_cols){
2296:     /* Matrix doesn't have all the columns in the buffer */
2299:     for (j=0; j < Matrix->max_cols; j++){
2300:       for (i=0; i < Matrix->rows; i++){
2301: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2315:     for (j=0; j < Matrix->cols; j++){
2317: 	for (i=0; i < Matrix->rows; i++){
2318: 	  value = dbm_internalgetValue(Matrix,i,j);
2331:     for (j=0; j < Matrix->cols; j++){
2332:       for (i=0; i < Matrix->rows; i++){
2333: 	value = dbm_internalgetValue(Matrix,i,j);
2354: double dbm_min(doubleBufferedMatrix Matrix,int naflag, int *foundfinite){
2365:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2367:   colsdone = Calloc(Matrix->cols,int);
2373:   if (Matrix->cols > Matrix->max_cols){
2374:     /* Matrix doesn't have all the columns in the buffer */
2376:     for (j=0; j < Matrix->max_cols; j++){
2377:       for (i=0; i < Matrix->rows; i++){
2378: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2392:     for (j=0; j < Matrix->cols; j++){
2394: 	for (i=0; i < Matrix->rows; i++){
2395: 	  value = dbm_internalgetValue(Matrix,i,j);
2411:     for (j=0; j < Matrix->cols; j++){
2412:       for (i=0; i < Matrix->rows; i++){
2413: 	value = dbm_internalgetValue(Matrix,i,j);
2435: double dbm_mean(doubleBufferedMatrix Matrix,int naflag){
2447:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2449:   colsdone = Calloc(Matrix->cols,int);
2451:   if (Matrix->cols > Matrix->max_cols){
2452:     /* Matrix doesn't have all the columns in the buffer */
2454:     for (j=0; j < Matrix->max_cols; j++){
2455:       for (i=0; i < Matrix->rows; i++){
2456: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2472:     for (j=0; j < Matrix->cols; j++){
2474: 	for (i=0; i < Matrix->rows; i++){
2475: 	  value = dbm_internalgetValue(Matrix,i,j);
2489:     for (j=0; j < Matrix->cols; j++){
2490:       for (i=0; i < Matrix->rows; i++){
2491: 	value = dbm_internalgetValue(Matrix,i,j);
2513: double dbm_sum(doubleBufferedMatrix Matrix,int naflag){
2524:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2526:   colsdone = Calloc(Matrix->cols,int);
2528:   if (Matrix->cols > Matrix->max_cols){
2529:     /* Matrix doesn't have all the columns in the buffer */
2531:     for (j=0; j < Matrix->max_cols; j++){
2532:       for (i=0; i < Matrix->rows; i++){
2533: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2547:     for (j=0; j < Matrix->cols; j++){
2549: 	for (i=0; i < Matrix->rows; i++){
2550: 	  value = dbm_internalgetValue(Matrix,i,j);
2563:     for (j=0; j < Matrix->cols; j++){
2564:       for (i=0; i < Matrix->rows; i++){
2565: 	value = dbm_internalgetValue(Matrix,i,j);
2584: double dbm_var(doubleBufferedMatrix Matrix,int naflag){
2598:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2600:   colsdone = Calloc(Matrix->cols,int);
2602:   if (Matrix->cols > Matrix->max_cols){
2603:     /* Matrix doesn't have all the columns in the buffer */
2605:     for (j=0; j < Matrix->max_cols; j++){
2606:       for (i=0; i < Matrix->rows; i++){
2607: 	value = dbm_internalgetValue(Matrix,i,BufferContents[j]);
2619: 	    mean = *dbm_internalgetValue(Matrix,i,BufferContents[j]);
2628:     for (j=0; j < Matrix->cols; j++){
2630: 	for (i=0; i < Matrix->rows; i++){
2631: 	  value = dbm_internalgetValue(Matrix,i,j);
2643: 	      mean = *dbm_internalgetValue(Matrix,i,j);
2652:     for (j=0; j < Matrix->cols; j++){
2653:       for (i=0; i < Matrix->rows; i++){
2654: 	value = dbm_internalgetValue(Matrix,i,j);
2666: 	    mean = *dbm_internalgetValue(Matrix,i,j);
2691: void dbm_rowMeans(doubleBufferedMatrix Matrix,int naflag,double *results){
2695:   int *counts = Calloc(Matrix->rows,int);
2696:   int *foundNA = Calloc(Matrix->rows,int);
2700:   for (i=0; i < Matrix->rows; i++){
2704:   for (j=0; j < Matrix->cols; j++){
2705:     for (i=0; i < Matrix->rows; i++){
2706:       value = dbm_internalgetValue(Matrix,i,j);
2718:   for (i=0; i < Matrix->rows; i++){
2736: void dbm_rowSums(doubleBufferedMatrix Matrix,int naflag,double *results){
2740:   int *foundNA = Calloc(Matrix->rows,int);
2744:   for (i=0; i < Matrix->rows; i++){
2748:   for (j=0; j < Matrix->cols; j++){
2749:     for (i=0; i < Matrix->rows; i++){
2750:       value = dbm_internalgetValue(Matrix,i,j);
2761:   for (i=0; i < Matrix->rows; i++){
2774: static void dbm_singlecolMeans(doubleBufferedMatrix Matrix,int j,int naflag,double *results){
2784:   for (i=0; i < Matrix->rows; i++){
2785:     value = dbm_internalgetValue(Matrix,i,j);
2807: void dbm_colMeans(doubleBufferedMatrix Matrix,int naflag,double *results){
2814:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2816:   colsdone = Calloc(Matrix->cols,int);
2818:   if (Matrix->cols > Matrix->max_cols){
2819:     /* Matrix doesn't have all the columns in the buffer */
2822:     for (j=0; j < Matrix->max_cols; j++){
2823:       dbm_singlecolMeans(Matrix,BufferContents[j],naflag,results);
2828:     for (j=0; j < Matrix->cols; j++){
2830: 	dbm_singlecolMeans(Matrix,j,naflag,results);
2834:     for (j=0; j < Matrix->cols; j++){
2835:       dbm_singlecolMeans(Matrix,j,naflag,results);
2844: static void dbm_singlecolSums(doubleBufferedMatrix Matrix,int j,int naflag,double *results){
2851:   for (i=0; i < Matrix->rows; i++){
2852:     value = dbm_internalgetValue(Matrix,i,j);
2869: void dbm_colSums(doubleBufferedMatrix Matrix,int naflag,double *results){
2876:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
2878:   colsdone = Calloc(Matrix->cols,int);
2880:   if (Matrix->cols > Matrix->max_cols){
2881:     /* Matrix doesn't have all the columns in the buffer */
2884:     for (j=0; j < Matrix->max_cols; j++){
2885:       dbm_singlecolSums(Matrix,BufferContents[j],naflag,results);
2890:     for (j=0; j < Matrix->cols; j++){
2892: 	dbm_singlecolSums(Matrix,j,naflag,results);
2896:     for (j=0; j < Matrix->cols; j++){
2897:       dbm_singlecolSums(Matrix,j,naflag,results);
2908: void dbm_rowVars(doubleBufferedMatrix Matrix,int naflag,double *results){
2912:   int *counts = Calloc(Matrix->rows,int);
2913:   int *foundNA = Calloc(Matrix->rows,int);
2914:   double *means = Calloc(Matrix->rows,double);
2918:   for (i=0; i < Matrix->rows; i++){
2919:     means[i] = *dbm_internalgetValue(Matrix,i,0);
2931:   for (j=1; j < Matrix->cols; j++){
2932:     for (i=0; i < Matrix->rows; i++){
2933:       value = dbm_internalgetValue(Matrix,i,j);
2944:   for (i=0; i < Matrix->rows; i++){ 
2946:     if (foundNA[i] == Matrix->cols){
2963: static void dbm_singlecolVars(doubleBufferedMatrix Matrix,int j,int naflag,double *results){
2973:     means = *dbm_internalgetValue(Matrix,0,j); 
2988:     for (i=1; i < Matrix->rows; i++){
2989:       value = dbm_internalgetValue(Matrix,i,j);  
3004:     if (foundNA == Matrix->rows){
3018: void dbm_colVars(doubleBufferedMatrix Matrix,int naflag,double *results){
3025:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
3027:   colsdone = Calloc(Matrix->cols,int);
3029:   if (Matrix->cols > Matrix->max_cols){
3030:     /* Matrix doesn't have all the columns in the buffer */
3033:     for (j=0; j < Matrix->max_cols; j++){
3034:       dbm_singlecolVars(Matrix,BufferContents[j],naflag,results);
3039:     for (j=0; j < Matrix->cols; j++){
3041: 	dbm_singlecolVars(Matrix,j,naflag,results);
3045:     for (j=0; j < Matrix->cols; j++){
3046:       dbm_singlecolVars(Matrix,j,naflag,results);
3059:  ** void dbm_rowMax(doubleBufferedMatrix Matrix,int naflag,double *results)
3071: void dbm_rowMax(doubleBufferedMatrix Matrix,int naflag,double *results){
3076:   int *isNA = Calloc(Matrix->rows,int);
3078:   for (i=0; i < Matrix->rows; i++){
3079:     results[i] = *dbm_internalgetValue(Matrix,i,0);
3090:   for (j=1; j < Matrix->cols; j++){
3091:     for (i=0; i < Matrix->rows; i++){
3092:       value = dbm_internalgetValue(Matrix,i,j);
3108:   for (i=0; i < Matrix->rows; i++){
3123: static void dbm_singlecolMax(doubleBufferedMatrix Matrix,int j, int naflag,double *results){
3128:   results[j] = *dbm_internalgetValue(Matrix,0,j);
3137:   for (i=1; i < Matrix->rows; i++){
3138:     value = dbm_internalgetValue(Matrix,i,j);
3153: void dbm_colMax(doubleBufferedMatrix Matrix,int naflag,double *results){
3161:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
3163:   colsdone = Calloc(Matrix->cols,int);
3165:   if (Matrix->cols > Matrix->max_cols){
3166:     /* Matrix doesn't have all the columns in the buffer */
3169:     for (j=0; j < Matrix->max_cols; j++){
3170:       dbm_singlecolMax(Matrix,BufferContents[j],naflag,results);
3175:     for (j=0; j < Matrix->cols; j++){
3177: 	dbm_singlecolMax(Matrix,j,naflag,results);
3181:     for (j=0; j < Matrix->cols; j++){
3182:       dbm_singlecolMax(Matrix,j,naflag,results);
3202: void dbm_rowMin(doubleBufferedMatrix Matrix,int naflag,double *results){
3207:   int *isNA = Calloc(Matrix->rows,int);
3209:   for (i=0; i < Matrix->rows; i++){
3210:     results[i] = *dbm_internalgetValue(Matrix,i,0);
3221:   for (j=1; j < Matrix->cols; j++){
3222:     for (i=0; i < Matrix->rows; i++){
3223:       value = dbm_internalgetValue(Matrix,i,j);
3239:   for (i=0; i < Matrix->rows; i++){
3254: static void dbm_singlecolMin(doubleBufferedMatrix Matrix,int j,int naflag,double *results){
3258:   results[j] = *dbm_internalgetValue(Matrix,0,j);
3267:   for (i=1; i < Matrix->rows; i++){
3268:       value = dbm_internalgetValue(Matrix,i,j);
3284: void dbm_colMin(doubleBufferedMatrix Matrix,int naflag,double *results){
3290:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
3292:   colsdone = Calloc(Matrix->cols,int);
3294:   if (Matrix->cols > Matrix->max_cols){
3295:     /* Matrix doesn't have all the columns in the buffer */
3298:     for (j=0; j < Matrix->max_cols; j++){
3299:       dbm_singlecolMin(Matrix,BufferContents[j],naflag,results);
3304:     for (j=0; j < Matrix->cols; j++){
3306: 	dbm_singlecolMin(Matrix,j,naflag,results);
3310:     for (j=0; j < Matrix->cols; j++){
3311:       dbm_singlecolMin(Matrix,j,naflag,results);
3338: static void dbm_singlecolMedian(doubleBufferedMatrix Matrix,int j,int naflag,double *results){
3342:   double *buffer = Calloc(Matrix->rows,double);
3345:   for (i=0; i < Matrix->rows; i++){
3346:     value = dbm_internalgetValue(Matrix,i,j);
3393: void dbm_colMedians(doubleBufferedMatrix Matrix,int naflag,double *results){
3399:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
3401:   colsdone = Calloc(Matrix->cols,int);
3403:   if (Matrix->cols > Matrix->max_cols){
3404:     /* Matrix doesn't have all the columns in the buffer */
3407:     for (j=0; j < Matrix->max_cols; j++){
3408:       dbm_singlecolMedian(Matrix,BufferContents[j],naflag,results);
3413:     for (j=0; j < Matrix->cols; j++){
3415: 	dbm_singlecolMedian(Matrix,j,naflag,results);
3419:     for (j=0; j < Matrix->cols; j++){
3420:       dbm_singlecolMedian(Matrix,j,naflag,results);
3430: static void dbm_singlecolRange(doubleBufferedMatrix Matrix,int j,int naflag,int finite, double *results){
3435:   /* Min is stored in results[0 , 2, ... 2*(Matrix->cols-1)] */
3436:   /* Max is stored in results[1, 3,  ... ,2*Matrix->cols -1] */
3439:   results[j*2] = *dbm_internalgetValue(Matrix,0,j);
3453:   if ((Matrix->rows %2) ==0){
3462:   for (i=start_ind; i < Matrix->rows; i=i+2){
3463:       value = dbm_internalgetValue(Matrix,i,j);
3464:       value1 = dbm_internalgetValue(Matrix,i+1,j);
3510: void dbm_colRanges(doubleBufferedMatrix Matrix,int naflag, int finite, double *results){
3516:   BufferContents= dbm_whatsInColumnBuffer(Matrix);
3518:   colsdone = Calloc(Matrix->cols,int);
3520:   if (Matrix->cols > Matrix->max_cols){
3521:     /* Matrix doesn't have all the columns in the buffer */
3524:     for (j=0; j < Matrix->max_cols; j++){
3525:       dbm_singlecolRange(Matrix,BufferContents[j],naflag,finite,results);
3530:     for (j=0; j < Matrix->cols; j++){
3532: 	dbm_singlecolRange(Matrix,j,naflag,finite,results);
3536:     for (j=0; j < Matrix->cols; j++){
3537:       dbm_singlecolRange(Matrix,j,naflag,finite,results);
3551: int dbm_memoryInUse(doubleBufferedMatrix Matrix){
3564:   if (Matrix->cols < Matrix->max_cols){
3565:     object_size+= Matrix->cols*sizeof(double *);
3566:     object_size+= Matrix->cols*Matrix->rows*sizeof(double);
3567:     object_size+= Matrix->cols*sizeof(int);
3569:     object_size+= Matrix->max_cols*sizeof(double *);
3570:     object_size+= Matrix->max_cols*Matrix->rows*sizeof(double);
3571:     object_size+= Matrix->max_cols*sizeof(int);
3575:   if (!Matrix->colmode){
3576:     object_size+= Matrix->cols*sizeof(double *);
3577:     if (Matrix->rows < Matrix->max_rows){
3578:       object_size+= Matrix->rows*Matrix->max_rows*sizeof(double);
3580:       object_size+= Matrix->cols*Matrix->max_rows*sizeof(double);
3586:   object_size+=strlen(Matrix->fileprefix) + 1;
3587:   object_size+=strlen(Matrix->filedirectory) + 1;
3589:   object_size+= Matrix->cols*sizeof(char *);
3590:   for (i=0; i < Matrix->cols; i++){
3591:     object_size+=strlen(Matrix->filenames[i]) +1;
3606: double dbm_fileSpaceInUse(doubleBufferedMatrix Matrix){
3608:   return (double)(Matrix->rows)*(double)Matrix->cols*(double)sizeof(double);
3616: void dbm_rowMedians(doubleBufferedMatrix Matrix,int naflag,double *results){
3620:   double *buffer = Calloc(Matrix->cols,double);
3625:   for (i = 0; i < Matrix->rows; i++){
3628:     for (j = 0; j < Matrix->cols; j++){
3629:       value = dbm_internalgetValue(Matrix,i,j);
3:  ** file: doubleBufferedMatrix.c
39: #include "doubleBufferedMatrix.h"
138:  ** of the doubleBufferedMatrix.
850:  ** doubleBufferedMatrix dbm_alloc(int max_rows,int max_cols,const char *prefix, const char *directory)
858:  ** RETURNS an allocated empty doubleBufferedMatrix. Note that this routine
866: doubleBufferedMatrix dbm_alloc(int max_rows,int max_cols,const char *prefix, const char *directory){
908:   return (doubleBufferedMatrix)handle;
beachmat:inst/include/beachmat/character_matrix.h: [ ]
28: class character_matrix {
107: class general_character_matrix : public character_matrix {
109:     general_character_matrix(const Rcpp::RObject& incoming) : reader(incoming) {}
186: using simple_character_matrix=general_character_matrix<simple_reader<Rcpp::String, Rcpp::StringVector> >;
197: using delayed_character_matrix=general_character_matrix<delayed_character_reader>;
201: using unknown_character_matrix=general_character_matrix<unknown_reader<Rcpp::String, Rcpp::StringVector> >;
208: using external_character_matrix=general_character_matrix<external_reader<Rcpp::String, Rcpp::StringVector> >;
226: inline std::unique_ptr<character_matrix> create_character_matrix(const Rcpp::RObject& incoming) { 
231: inline std::unique_ptr<character_matrix> create_matrix<character_matrix>(const Rcpp::RObject& incoming) {
2: #define BEACHMAT_CHARACTER_MATRIX_H
212: inline std::unique_ptr<character_matrix> create_character_matrix_internal(const Rcpp::RObject& incoming, bool delayed) { 
1: #ifndef BEACHMAT_CHARACTER_MATRIX_H
30:     character_matrix() = default;
31:     virtual ~character_matrix() = default;
32:     character_matrix(const character_matrix&) = default;
33:     character_matrix& operator=(const character_matrix&) = default;
34:     character_matrix(character_matrix&&) = default;
35:     character_matrix& operator=(character_matrix&&) = default;
88:     virtual std::unique_ptr<character_matrix> clone() const=0;
102: std::unique_ptr<character_matrix> create_character_matrix_internal(const Rcpp::RObject&, bool); 
104: /* Advanced character matrix template */
110:     ~general_character_matrix() = default;
111:     general_character_matrix(const general_character_matrix&) = default;
112:     general_character_matrix& operator=(const general_character_matrix&) = default;
113:     general_character_matrix(general_character_matrix&&) = default;
114:     general_character_matrix& operator=(general_character_matrix&&) = default;
120:     using character_matrix::get_row;
126:     using character_matrix::get_col;
139:     using character_matrix::get_col_raw;
145:     using character_matrix::get_row_raw;
160:     using character_matrix::get_rows;
166:     using character_matrix::get_cols;
173:     std::unique_ptr<character_matrix> clone() const { return std::unique_ptr<character_matrix>(new general_character_matrix(*this)); }
184: /* Simple character matrix */
190: typedef delayed_reader<Rcpp::String, Rcpp::StringVector, character_matrix> delayed_character_reader;
193: inline std::unique_ptr<character_matrix> delayed_character_reader::generate_seed(Rcpp::RObject incoming) {
194:     return create_character_matrix_internal(incoming, false);
199: /* Unknown matrix type */
203: /* External matrix type */
216:             return std::unique_ptr<character_matrix>(new delayed_character_matrix(incoming));
218:             return std::unique_ptr<character_matrix>(new external_character_matrix(incoming));
220:         return std::unique_ptr<character_matrix>(new unknown_character_matrix(incoming));
223:     return std::unique_ptr<character_matrix>(new simple_character_matrix(incoming));
227:     return create_character_matrix_internal(incoming, true);
232:     return create_character_matrix(incoming);
302: /* General character matrix */
381: /* Simple character matrix */
385: /* External character matrix */
188: /* DelayedMatrix */
215:         if (delayed && ctype=="DelayedMatrix") { 
HiCcompare:R/sim_matrix.R: [ ]
200: sim_matrix <- function(nrow = 100, medianIF = 50000, sdIF = 14000,
18: # simulate matrix function will create a two full contact maps.
26:          greater than 1 at the maximum distance in the matrix.")
28:   cell1 <- matrix(nrow = nrow, ncol = ncol)
29:   cell2 <- matrix(nrow = nrow, ncol = ncol)
67: # function to add bias to a matrix
109:   new.idx <- as.matrix(new.idx)
121: #' @param nrow Number of rows and columns of the full matrix
123: #'     for the interaction frequency of the matrix. Should use the median
138: #'     the probability of zero in matrix = slope * distance
142: #'     in a 100x100 matrix starting at column 47 and ending at column 50
144: #'     simulated centromere will be added to the matrix.
148: #'     in a 100x100 matrix starting at column 1 and ending at column 50
162: #'     function will be multiplied to the IFs of one matrix.
216:          you wish to produce a fold change in the simulated matrix")
223:       stop('centromere.location is outside the bounds of the matrix')
235:       stop('CNV.location is outside the bounds of the matrix')
243:   # if fold.change = NA no true differences will be added to the matrix
254:   # add in sample specific bias to one matrix
258:   # add centromere to matrix
267:   # add CNV to matrix
272:   # convert matrix to sparse format
KBoost:R/AUPR_AUROC_matrix.R: [ ]
18: AUPR_AUROC_matrix <- function(Net,G_mat, auto_remove,TFs, upper_limit){
5: #'@param G_mat A matrix with the gold standard network.
10: #'@return list object with AUPR and AUROC of gold standard in matrix format.
15: #'     g_mat1 = tab_2_matrix_D4(KBoost::G_D4_multi_1,100)
16: #'     aupr_auroc = AUPR_AUROC_matrix(Net$GRN,g_mat1,auto_remove = TRUE,  seq_len(100))
21:         g_mat <- matrix(0,(dim(Net)[1]-1)*(dim(Net)[2]),1)
22:         net <- matrix(0,(dim(Net)[1]-1)*(dim(Net)[2]),1)
37:         G_mat <- matrix(G_mat,dim(Net)[1]*dim(Net)[2],1)
38:         Net <- matrix(Net,dim(Net)[1]*dim(Net)[2],1)
49:     TP <- matrix(0,length(Net),1)
recount:R/coverage_matrix.R: [ ]
71: coverage_matrix <- function(project, chr, regions, chunksize = 1000,
193:     coverageMatrix <- do.call(rbind, lapply(resChunks, "[[", "coverageMatrix"))
1: #' Given a set of regions for a chromosome, compute the coverage matrix for a
5: #' function computes the coverage matrix for a library size of 40 million 100 bp
10: #' for `chr` for which to calculate the coverage matrix.
12: #' computing the coverage matrix. Regions will be split into different chunks
16: #' will be used to calculate the coverage matrix in parallel. By default,
43: #' `coverage_matrix_bwtool()`.
65: #'     ## Now calculate the coverage matrix for this study
66: #'     rse <- coverage_matrix("DRP002835", "chrY", regions)
53: #' [railMatrix][derfinder::railMatrix]
195:     if (round) coverageMatrix <- round(coverageMatrix, 0)
199:         assays = list("counts" = coverageMatrix),
edgeR:R/makeCompressedMatrix.R: [ ]
43: .strip_to_matrix <- function(x) {
1: makeCompressedMatrix <- function(x, dims, byrow=TRUE) 
50: dim.CompressedMatrix <- function(x) 
59: length.CompressedMatrix <- function(x)
135: as.matrix.CompressedMatrix <- function(x, ...) 
156: rbind.CompressedMatrix <- function(...) 
216: cbind.CompressedMatrix <- function(...) 
276: Ops.CompressedMatrix <- function(e1, e2)
69: `[.CompressedMatrix` <- function(x, i, j, drop=TRUE)
116: `[<-.CompressedMatrix` <- function(x, i, j, value) 
2: # Coerces a NULL, scalar, vector or matrix to a compressed matrix,
11: 	if (is.matrix(x)) {
18: 		x <- matrix(x)
78:         return(as.matrix(x)[i])
81:     raw.mat <- .strip_to_matrix(x)
111:         raw.mat <- as.vector(as.matrix(raw.mat))
122:     ref <- as.matrix(x)
124:         value <- as.matrix(value)
136: # Expanding it to a full matrix.
142:     raw.mat <- .strip_to_matrix(x)
147:         raw.mat <- matrix(raw.mat, nrow(x), ncol(x), byrow=TRUE)                
149:         raw.mat <- matrix(raw.mat, nrow(x), ncol(x))
151:         raw.mat <- as.matrix(raw.mat)
186:             collected.vals[[i]] <- rep(.strip_to_matrix(current), length.out=nrow(current))
194:         ref <- .strip_to_matrix(everything[[1]])
196:             current <- .strip_to_matrix(everything[[i]])
211:         everything[[i]] <- as.matrix(everything[[i]])
246:             collected.vals[[i]] <- rep(.strip_to_matrix(current), length.out=ncol(current))
254:         ref <- .strip_to_matrix(everything[[1]])
256:             current <- .strip_to_matrix(everything[[i]])
271:         everything[[i]] <- as.matrix(everything[[i]])
299:         e1 <- as.vector(.strip_to_matrix(e1))
300:         e2 <- as.vector(.strip_to_matrix(e2))
304:         e1 <- as.matrix(e1)
305:         e2 <- as.matrix(e2)
317: # as the sum of counts in the count matrix 'y'.
12: 		if (inherits(x, "CompressedMatrix")) {
36:     class(x) <- "CompressedMatrix"
70: # Subsetting for CompressedMatrix objects.
117: # Subset assignment for CompressedMatrix objects.
123:     if (is(value, "CompressedMatrix")) { 
132:     makeCompressedMatrix(ref, attr(x, "Dims"), TRUE)
184:                 stop("cannot combine CompressedMatrix objects with different number of columns")
188:         return(makeCompressedMatrix(unlist(collected.vals), dims=c(all.nr, all.nc), byrow=FALSE))
213:     return(makeCompressedMatrix(do.call(rbind, everything)))
244:                 stop("cannot combine CompressedMatrix objects with different number of rows")
248:         return(makeCompressedMatrix(unlist(collected.vals), dims=c(all.nr, all.nc), byrow=TRUE))
273:     return(makeCompressedMatrix(do.call(cbind, everything)))
277: # A function that performs some binary operation on two CompressedMatrix objects,
284:     if (!inherits(e1, "CompressedMatrix")) {
285:         e1 <- makeCompressedMatrix(e1, dim(e2), byrow=FALSE) # Promoted to column-major CompressedMatrix 
287:     if (!inherits(e2, "CompressedMatrix")) {
288:         e2 <- makeCompressedMatrix(e2, dim(e1), byrow=FALSE)       
291:         stop("CompressedMatrix dimensions should be equal for binary operations")
302:         outcome <- makeCompressedMatrix(outcome, new.dim, byrow=row.rep)
307:         outcome <- makeCompressedMatrix(outcome)
319: # If 'offset' is already of the CompressedMatrix class, then 
322: 	if (inherits(offset, "CompressedMatrix")) {
331: 	offset <- makeCompressedMatrix(offset, dim(y), byrow=TRUE)
344: # If 'weights' is already a CompressedMatrix, then we assume it's 
347: 	if (inherits(weights, "CompressedMatrix")) {
353: 	weights <- makeCompressedMatrix(weights, dim(y), byrow=TRUE)
364: # Skipping the check if it's already a CompressedMatrix object.
366: 	if (inherits(prior.count, "CompressedMatrix")) {
371: 	prior.count <- makeCompressedMatrix(prior.count, dim(y), byrow=FALSE)
382: # Skipping the check if it's already a CompressedMatrix object.
384: 	if (inherits(dispersion, "CompressedMatrix")) {
389: 	dispersion <- makeCompressedMatrix(dispersion, dim(y), byrow=FALSE)
genomation:R/patternMatrix.R: [ ]
73: .patternPWM_windowsDNAStringSet2matrix = function(pattern, windows, 
122: .patterncharacter_windowsDNAStringSet2matrix = function(pattern, windows, cores){
12: # pwm: matrix, seq: character
70: # Find positions of specified PWM and calculate score matrix
72: # pwm: matrix, windows: character
93:       mat <- matrix(unlist(mat), ncol = length(mat[[1]]), byrow = TRUE)
104:     # convert list to matrix
105:     mat <- matrix(unlist(pwm.match), ncol = length(pwm.match[[1]]), byrow = TRUE)
173:   # convert list to matrix
174:   mat <- matrix(unlist(pwm.match), ncol = length(pwm.match[[1]]), byrow = TRUE)
183: #' Get scores that correspond to k-mer or PWM matrix occurrence for bases in each window
185: #' The function produces a base-pair resolution matrix or matrices of scores that correspond to 
186: #' k-mer or PWM matrix occurrence over predefined windows that  have equal width.
188: #' creates score matrix filled with 1 (presence of pattern) and 0 (its absence) or
189: #' matrix with scores themselves.
190: #' If pattern is a character of length 1 or PWM matrix then the function returns 
194: #' @param pattern matrix (a PWM matrix), list of matrices or a character vector of length 1 or more.
195: #'                A matrix is a PWM matrix that needs to have one row for each nucleotide 
215: #' and adapted function motifScanHits to find pattern that is a PWM matrix
266:                 mat <- .patterncharacter_windowsDNAStringSet2matrix(pattern, windows, cores=cores)
271:                              function(i) .patterncharacter_windowsDNAStringSet2matrix(pattern[i],
305: #' @aliases patternMatrix,matrix,DNAStringSet-method
307: #' @usage  \\S4method{patternMatrix}{matrix,DNAStringSet}(pattern, windows,
311:           signature(pattern = "matrix", windows = "DNAStringSet"),
319:             mat <- .patternPWM_windowsDNAStringSet2matrix(pattern, windows, 
325: #' @aliases patternMatrix,matrix,GRanges,BSgenome-method
327: #' @usage  \\S4method{patternMatrix}{matrix,GRanges,BSgenome}(pattern, windows, genome,
331:           signature(pattern = "matrix", windows = "GRanges", genome="BSgenome"),
355:             # pattern: matrix, windows: DNAStringSet
371:             if(inherits(pattern[[1]], "matrix")){
397:             if(inherits(pattern[[1]],"matrix")){
191: #' a ScoreMatrix object, if character of length more than 1 or list of PWMs 
206: #'                  then \code{patternMatrix} returns scores themselves (default).
212: #' \code{patternMatrix} is based on functions from the seqPattern package:
229: #' p = patternMatrix(pattern=motif, windows=windows, min.score=0.8)
232: #' @return returns a \code{scoreMatrix} object or a \code{scoreMatrixList} object
234: #' @seealso \code{\link{ScoreMatrix}}, \code{\link{ScoreMatrixList}}
236: #' @rdname patternMatrix-methods           
239:   name="patternMatrix",
243:     standardGeneric("patternMatrix")
247: #' @aliases patternMatrix,character,DNAStringSet-method
248: #' @rdname patternMatrix-methods
249: #' @usage  \\S4method{patternMatrix}{character,DNAStringSet}(pattern, windows,
251: setMethod("patternMatrix",
265:                 # if there is only one pattern then create ScoreMatrix
267:                 return(new("ScoreMatrix",mat))
278: #' @aliases patternMatrix,character,GRanges,BSgenome-method
279: #' @rdname patternMatrix-methods
280: #' @usage  \\S4method{patternMatrix}{character,GRanges,BSgenome}(pattern, windows, genome,
282: setMethod("patternMatrix",
299:             # call patternMatrix function
301:             patternMatrix(pattern=pattern, windows=windows,
306: #' @rdname patternMatrix-methods
310: setMethod("patternMatrix",
322:             return(new("ScoreMatrix",mat))
326: #' @rdname patternMatrix-methods
330: setMethod("patternMatrix",
354:             # call patternMatrix function
356:             patternMatrix(pattern=pattern, windows=windows, 
361: #' @aliases patternMatrix,list,DNAStringSet-method
362: #' @rdname patternMatrix-methods
363: #' @usage  \\S4method{patternMatrix}{list,DNAStringSet}(pattern, windows,
366: setMethod("patternMatrix",
373:                             function(i) patternMatrix(pattern=pattern[[i]], 
383:               patternMatrix(pattern, windows, min.score)
387: #' @aliases patternMatrix,list,GRanges,BSgenome-method
388: #' @rdname patternMatrix-methods
389: #' @usage  \\S4method{patternMatrix}{list,GRanges,BSgenome}(pattern, windows, genome, 
392: setMethod("patternMatrix",
399:                             function(i) patternMatrix(pattern=pattern[i], 
410:               patternMatrix(pattern, windows, genome=genome, 
192: #' then ScoreMatrixList.
274:                 return(new("ScoreMatrixList", lmat))
378:               return(new("ScoreMatrixList",lmat))
405:               return(new("ScoreMatrixList",lmat))
EGAD:R/get_expression_matrix_from_GEO.R: [ ]
39:     data.matrix <- do.call("cbind", 
19: get_expression_matrix_from_GEO <- function(gseid) {
1: #' Obtain expression matrix from GEO database
3: #' The function downloads and parses the expression matrix from the GEO file 
8: #' @return list of genes and the expression matrix 
49:     data.matrix <- apply(data.matrix, 2, function(x) {
54:     rownames(data.matrix) <- probesets
55:     colnames(data.matrix) <- names(GSMList(gseSOFT))
60:     data.matrix <- data.matrix[use_probe, ]
61:     rownames(data.matrix) <- ORF[use_probe]
64:     Med <- median(data.matrix, na.rm = TRUE)
65:     if (Med > 16) { data.matrix <- log2(data.matrix)}
69:     na.length <- length(which(is.na(data.matrix) == TRUE))
71:         data.matrix <- impute.knn(data.matrix)$data
73:     data.matrix <- normalizeBetweenArrays(data.matrix)
76:     tmp <- aggregate(data.matrix, list(rownames(data.matrix)), median)
77:     data.matrix <- as.matrix(tmp[, -1])
79:     rownames(data.matrix) <- genes
84:     return(list(genes, data.matrix))
22:     gseSOFT <- getGEO(GEO = gseid, GSEMatrix = FALSE)
Rbec:R/error_matrix_multicore.R: [ ]
102:     trans_matrix <- trans_m(query, ascii)
103:     error_matrix <- loessErr(trans_matrix)
135:     error_ref_matrix <- list(ref=ref, err=error_matrix, derep=derep1, total_reads=length(raw_data)/4)
4: #' This function calculate the error matrix
11: #' @param sample_size the sampling size of reads to generate the transition matrix
23: #' @return The output is a 20 by 43 transition probability matrix
90:     # sample raw sequences for transition matrix generation
101:     # calculate the transition matrix and error matrix
124:           tp <- apply(data4lambda, 1, function(x) error_matrix[x[1], x[2]])
136:     return(error_ref_matrix)
MetaboSignal:R/metabolic_matrix.R: [ ]
126: metabolic_matrix = function(path_names, list_parsed_paths, organism_code,
11:         line = matrix(line, ncol = 4, nrow = length(reactions))
86: bind_reaction_gene = function (reaction, matrix) {
87:     index_reaction = which(matrix[, 1] == reaction)
89:       reaction_genes = paste(reaction, matrix[index_reaction, 2], sep = "_")
110:         reaction_genes_all = bind_reaction_gene(reaction, matrix = reactionko)
113:         reaction_genes_all = bind_reaction_gene(reaction, matrix = reactiongene)
125: #################### metabolic_matrix ####################
131:     metabolic_table = matrix(metabolic_table, ncol = 2)
148:     if (is.matrix(enzymeTable) & is.matrix(reactionTable) & is.matrix(koTable)) {
179:         metabolic_table_RG = matrix(metabolic_table_RG, ncol = 2)