This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(hrbrthemes) | |
library(janitor) | |
read.csv(text='"Party","Votes in all of the U.K.","Votes only in Scotland" | |
"Labour",33.7,35.27801359 | |
"Conservative",23.7,12.72746096 | |
"Reform UK",14.3,6.956199453 | |
"Liberal\nDemocrats",12.2,9.699645107 | |
"Greens",6.7,3.838190168 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2);data(mtcars) | |
do_sampling = T | |
if (do_sampling==T){ | |
if(!is.logical(do_sampling)) stop() | |
my_cars<- mtcars[,sample(ncol(mtcars), repl = F)] | |
} else | |
{ | |
my_cars = mtcars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -o nounset | |
# This script uses a GTF file (e.g. generated by Stringtie) and | |
# 1. retrieves BAM files for individual samples from AWS S3 | |
# 2. quantifies the exons defined in the GTF file with featureCounts, | |
# e.g. for differential splicing analysis with limma::diffSplice | |
# | |
# Alignments are expected to be reverse-stranded and paired-end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Commented out IPython magic to ensure Python compatibility. | |
# %%capture | |
# !pip install awswrangler --quiet | |
import awswrangler as wr | |
import pandas as pd | |
import boto3 | |
from google.colab import data_table, userdata | |
data_table.enable_dataframe_formatter() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from google.colab import userdata | |
# refresh the temporary credentials via the key symbol in the left hand tab | |
s3_resource = boto3.resource('s3', | |
aws_access_key_id=userdata.get('AWS_ACCESS_KEY_ID'), | |
aws_secret_access_key=userdata.get('AWS_SECRET_ACCESS_KEY'), | |
aws_session_token=userdata.get('AWS_SESSION_TOKEN') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(glue) | |
library(RSQLite) | |
con <- dbConnect(RSQLite::SQLite(), ":memory:") | |
var = "test" | |
glue_sql("{var}", .con = con) # <SQL> 'test' | |
glue_sql("{`var`}", .con = con) # <SQL> `test` | |
glue_sql("{DBI::SQL(var)}", .con = con) # <SQL> test (unquoted) | |
glue_sql("`{var}`", .con = con) # <SQL> `'test'` NOT USEFUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following code is based on the shiny::conditionalPanel() help page. The `ui` and `server` | |
# components have been compartmentalized into the `mod_histogram` module. The `histogramApp` | |
# function shows an example of using this module. | |
# Note that the `ns = ns` argument needs to be passed ot the conditionalPanel() call. | |
library(shiny) | |
mod_histogram_ui <- function(id){ | |
ns <- NS(id) | |
fluidPage( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(glue) | |
library(httr) | |
library(jsonlite) | |
library(xml2) | |
#' Query ENA's REST API for information about records | |
#' | |
#' @param accessions Character vector of one or more ENA record identifiers | |
#' @return An `xml_document` object | |
get_records <- function(accessions) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(palmerpenguins) | |
library(shiny) | |
library(shinyjqui) | |
categories <- colnames(penguins)[vapply(penguins, is.factor, logical(1))] | |
server <- function(input, output) { | |
lapply(categories, \(category) { | |
output[[category]] <- renderPrint({ print(input[[category]]) }) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Create an image tag with an example image | |
#' | |
#' @param width Scalar integer, the width of the image | |
#' @param height Scalar integer, the height of the image | |
#' @param title Scalar character, the title of the image | |
#' @return A `shiny.tag` with the URL to a random image from | |
#' [Lorem Picsum](https://picsum.photos/) | |
#' @export | |
#' @importFrom htmltool tags | |
#' @importFrom checkmate assert_count assert_character |
NewerOlder