Name: Zhuoyan Xu
Email: zhuoyan.xu@wisc.edu
knitr::opts_chunk$set( cache = TRUE, collapse = TRUE, comment = "#>", dpi = 200, echo = TRUE, fig.align = "center", fig.height = 8, fig.width = 8, message = FALSE, out.width = 650, warning = FALSE )
library(waveST) library(fields) library(tidyverse) theme_set(theme_minimal())
wave = waveST(data = raws[, 1:5]) decomp = decompose(wave, "raw", "SVD", K = 5) plot(decomp, k = 1, wave = FALSE) decomp = decompose(wave, "wave", "SVD", K = 5, tau = 40) plot(decomp, k = 1, wave = TRUE)
########## ================== Data Generation NUM_GENES = 300 K = 9 ## == Step 1. generate coordinate matrix image with different patterns # @N_dup, generate duplicates of each matrix pattern with a little permutation CMls = generateCoorM(1)
We show all the generated pattern:
# show in scaled version lay = layout(matrix(1:9, 3, 3, byrow = TRUE)) CMls %>% map(~ .x / sqrt(sum(.x^2))) %>% map(~ image.plot(.x, asp = 1)) layout(1)
We treat previous 9 patterns as factor genes, i.e. we have 8 factors matrix F = D^2xK (1024x8), where 1024 comes from (D^2) 32^2. We consider p = 500 genes in this simulation generate nxp(1024x500) data matrix by F%*%V, where V is \code{K}xp (8x500), compute the magnitude of each image matrix
scales = CMls %>% map_dbl(~ sqrt(sum(.x^2))) ## rescale each image matrix to norm 1 (eigen gene has norm 1) FctGenes = CMls %>% map(~ .x / sqrt(sum(.x^2))) %>% map_dfc(~ as.vector(.)) %>% as.matrix() LoadGenes = rep(1000, 9) %>% map_dfc(~ .x * rnorm(NUM_GENES)) %>% as.matrix(.) %>% t(.) truth = FctGenes %*% LoadGenes ## we generate data by add random noise raws = truth + matrix(rnorm(prod(dim(truth)), mean = 0, sd = 190), nrow = dim(truth)[1], ncol = dim(truth)[2]) wave = waveST(data = raws)
Without wavelet:
decomp = decompose(wave, "raw", "SVD", K = 5) plot(decomp, k = 1, wave = FALSE)
With wavelet:
decomp = decompose(wave, "wave", "SVD", K = 5, tau = 40) plot(decomp, k = 1, wave = TRUE)
res = kOverA_ST(k = 3, A = 7) viz = res$viz df = res$df
Without wavelet:
wave = waveST(data = df[, 1:5], spatial = viz) decomp = decompose(wave, "raw", "SVD", K = 5) plot(decomp, k = 1, wave = FALSE)
With wavelet:
decomp = decompose(wave, "wave", "SVD", K = 5, tau = 40) plot(decomp, k = 1, wave = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.