Skip to content

Test Jupiter and Rstudio

Rscript -e "rmarkdown::render('runtime.Rmd',params=list(args = myarg))"
Rscript -e "rmarkdown::render('runtime.Rmd')"
Rscript -e "rmarkdown::render('runtimeHTML.Rmd')"
Rscript -e "rmarkdown::render('rFutureHTML.Rmd')"

https://stackoverflow.com/questions/49904943/run-rmarkdown-with-arguments-on-the-command-line

Adding the myarg object as a parameter is the way to go:

Rscript -e "rmarkdown::render('example.Rmd',params=list(args = myarg))"

And then add the parameter to your Rmd file:

---
title: "Simple example"
output:
  pdf_document: default
params:
  args: myarg
---

Documentation on parameterized reports here: https://rmarkdown.rstudio.com/developer_parameterized_reports.html

cat >runtime.R <<-"EOF"
sleep_for_a_minute <- function() { Sys.sleep(2) }
# Start timer
start_time <- Sys.time()
sleep_for_a_minute()

# Stop timer
end_time <- Sys.time()
sink('runtime.txt')
cat("start_time =", start_time, "\n")
cat("end_time =", end_time, "\n")
end_time - start_time
# Stop writing to the file
sink()
system("~/data/bin/send2email -t s.winuthayanon@wsu.edu -s 'analysis runtime' -m runtime.txt", intern = TRUE, ignore.stderr = TRUE)
system("rm -f runtime.txt")
EOF

Rscript runtime.R 
vi test.Rmd

```{r}
# Start timer
sleep_for_a_minute <- function() { Sys.sleep(65) }
start_time <- Sys.time()
sleep_for_a_minute()

# Stop timer
end_time <- Sys.time()
end_time - start_time

```
# R runtime
ptm <- proc.time()
h <- g + 1
proc.time() - ptm

   user  system elapsed 
   0.00    0.02    0.01

Bash script

#!/bin/bash
for i in {1..1000}
do
    sleep 1
    echo "Welcome $i times"
done

R script

Second <- function(x)
{
    tmpP <- proc.time()
    Sys.sleep(x)
    proc.time() - tmpP
}

for (x in 1:1000) {
  print(x)
  Second(1)
}

install.packages('txtplot')
library('txtplot')
txtplot(cars[,1], cars[,2], xlab = 'speed', ylab = 'distance')

install.packages( "ggplot2", dependencies = TRUE )
install.packages('profvis')
library(ggplot2)
library(profvis)
profvis({
  data(diamonds, package = "ggplot2")

  plot(price ~ carat, data = diamonds)
  m <- lm(price ~ carat, data = diamonds)
  abline(m, col = "red")
})


install.packages( "devtools", dependencies = TRUE )
devtools::install_github("eddelbuettel/rbenchmark")
library(rbenchmark)

benchmark("lm" = {
            X <- matrix(rnorm(1000), 100, 10)
            y <- X %*% sample(1:10, 10) + rnorm(100)
            b <- lm(y ~ X + 0)$coef
          },
          "pseudoinverse" = {
            X <- matrix(rnorm(1000), 100, 10)
            y <- X %*% sample(1:10, 10) + rnorm(100)
            b <- solve(t(X) %*% X) %*% t(X) %*% y
          },
          "linear system" = {
            X <- matrix(rnorm(1000), 100, 10)
            y <- X %*% sample(1:10, 10) + rnorm(100)
            b <- solve(t(X) %*% X, t(X) %*% y)
          },
          replications = 1000,
          columns = c("test", "replications", "elapsed",
                      "relative", "user.self", "sys.self"))


install.packages( "ggplot2", dependencies = TRUE )
library(ggplot2)

install.packages( "tidyverse", dependencies = TRUE )
install.packages( "data.table", dependencies = TRUE )
install.packages( "sqldf", dependencies = TRUE )
install.packages( "stringdist", dependencies = TRUE )
install.packages( "RODBC", dependencies = TRUE )
install.packages( "xts", dependencies = TRUE )
install.packages( "dygraphs", dependencies = TRUE )
install.packages( "openxlsx", dependencies = TRUE )
install.packages( "lubridate", dependencies = TRUE )
install.packages( "forecast", dependencies = TRUE )
install.packages( "mailR", dependencies = TRUE )
install.packages( "gbm", dependencies = TRUE )
install.packages( "xgboost", dependencies = TRUE )
install.packages( "aTSA", dependencies = TRUE )
install.packages( "rattle", dependencies = TRUE )
install.packages( "Rcmdr", dependencies = TRUE )
install.packages( "itsmr", dependencies = TRUE )
install.packages( "stlplus", dependencies = TRUE )
library(stlplus)

sudo rstudio-server stop
sudo rstudio-server start
sudo rstudio-server restart
sudo rstudio-server status

install.packages('BiocManager', dependencies = TRUE)
BiocManager::install()
BiocManager::install('multtest')
# install.packages('Seurat', dependencies = TRUE)
remotes::install_github("satijalab/seurat", ref = "release/4.0.0")



install.packages( "dplyr", dependencies = TRUE )
# install.packages( "Seurat", dependencies = TRUE )
# remotes::install_github("satijalab/seurat", ref = "release/4.0.0")
remotes::install_github("satijalab/seurat", ref = "release/4.0.2")

install.packages( "patchwork", dependencies = TRUE )
library(dplyr)
library(seurat)
library(patchwork)

ERROR: dependencies "igraph", "irlba", "leiden", "lmtest", "Rtsne", "sctransform", "SeuratObject", "spatstat.core", "spatstat.geom", "uwot", "RcppEigen" are not available for package "Seurat"
install.packages( "igraph", "irlba", "leiden", "lmtest", "Rtsne", "sctransform", "SeuratObject", "spatstat.core", "spatstat.geom", "uwot", "RcppEigen", dependencies = TRUE )

install.packages( "igraph")
install.packages( "irlba")
install.packages( "leiden")
install.packages( "lmtest")
install.packages( "Rtsne")
install.packages( "sctransform")
install.packages( "SeuratObject")
install.packages( "spatstat.core")
install.packages( "spatstat.geom")
install.packages( "uwot")
install.packages( "RcppEigen")
install.packages( "hdf5r")


install.packages("Seurat")
# install.packages( "remotes")
remotes::install_github("mojaveazure/seurat-disk")
if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}
# remotes::install_github("mojaveazure/seurat-disk")

library(Seurat)
library(SeuratDisk)
library(ggplot2)
library(patchwork)
reference <- LoadH5Seurat("/home/nine/data/pbmc_multimodal.h5seurat")
DimPlot(object = reference, reduction = "wnn.umap", group.by = "celltype.l2", label = TRUE, label.size = 3, repel = TRUE) + NoLegend()

# install.packages( "SeuratData")
# library(SeuratData)
# Devtools
install.packages('devtools')
library(devtools)

# Seuratdata
devtools::install_github('satijalab/seurat-data')

# Seurat wrappers
devtools::install_github('satijalab/seurat-wrappers')

# Load packages
library(Seurat)
library(ggplot2)
library(patchwork)
library(SeuratData)
library(SeuratWrappers)

library(Seurat)
install.packages('Signac')
library(Signac)
BiocManager::install("EnsDb.Hsapiens.v86")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
library(EnsDb.Hsapiens.v86)
library(dplyr)
library(ggplot2)

ERROR: dependencies GenomeInfoDb, GenomicRanges, IRanges, Rsamtools, S4Vectors, BiocGenerics are not available for package Signac
# http://www.bioconductor.org/packages/release/bioc/html/GenomeInfoDb.html

BiocManager::install("GenomeInfoDb")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("GenomicRanges")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("IRanges")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("Rsamtools")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("S4Vectors")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("BiocGenerics")
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")


library(dplyr)
library(Seurat)
library(patchwork)

# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "/home/nine/data/filtered_gene_bc_matrices/hg19/")
# Initialize the Seurat object with the raw (non-normalized data).
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200)
pbmc


Second <- function(x)
{
    tmpP <- proc.time()
    Sys.sleep(x)
    proc.time() - tmpP
}

for (x in 1:1000) {
  print(x)
  Second(1)
}

#!/bin/bash
for i in {1..1000}
do
    sleep 1
    echo "Welcome $i times"
done

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *