Categories
Tag: RDocumentation
stat_quant_band function – RDocumentation
ggplot(mpg, aes(displ, hwy)) + geom_point() + stat_quant_band() # If you need the fitting to be done along the y-axis set the orientation ggplot(mpg, aes(displ, hwy)) + geom_point() + stat_quant_band(orientation = “y”) ggplot(mpg, aes(displ, hwy)) + geom_point() + stat_quant_band(formula = y ~ x) ggplot(mpg, aes(displ, hwy)) + geom_point() + stat_quant_band(formula =…
labkey.deleteRows function – RDocumentation
if (FALSE) { ## Insert, update and delete ## Note that users must have the necessary permissions in the LabKey Server ## to be able to modify data through the use of these functions # library(Rlabkey) newrow <- data.frame( DisplayFld=”Inserted from R” , TextFld=”how its done” , IntFld= 98 ,…
theme_stata function – RDocumentation
library(“ggplot2”) p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + facet_wrap(~ am) + labs(title = “Graphs by car type”, x = “Weight (lbs.)”, y = “MPG”) # s2color p + theme_stata() + scale_colour_stata(“s2color”) # s2mono p + theme_stata(scheme = “s2mono”) + scale_colour_stata(“mono”) # s1color p…
R Swirl 8.png – Rstudio File O – Edit Code -l View Session &0 9 | Untitled1* #” Build Debug Profile Go to
)Rstudio FileEditCodeViewPlotsSessionBuildDebugProfileToolsHelp O-l&0#”Gotofile/function~Addins~ 9|Untitled1*@|Untitled1*;—SourceonSave&/-1Tibrary(swirl) 2 3 456 7 8 6:1(TopLevel)2ConsoleTerminalBackgroundJobsRR431.~/ |Youarequitegoodmyfriend! [—|40% |whathappensinthiscaseisthatthe |Teftoperand“TRUE1isrecycledacross |everyelementinthevectoroftheright |operand.Thisistheequivalentstatement|asc(TRUE,TRUE,TRUE)&c(TRUE,FALSE, |FALSE). |========———e|42% |Nowwe’lltypethesameexpressionexcept |we’llusethe&operator.Typethe |expressionTRUE&&c(TRUE,FALSE,FALSE). >TRUE&%c(TRUE,FALSE,FALSE) ErrorinTRUE&&c(TRUE,FALSE,FALSE): ‘”length=3″1incoercionto‘logical(1)’ >TRUE&&c(TRUE,FALSE,FALSE) ErrorinTRUE&c(TRUE,FALSE,FALSE): ‘lTength=3′1incoercionto‘logical(1)’ >TRUE&&C(TRUE,FALSE,FALSE)ErrorinTRUE&c(TRUE,FALSE,FALSE): ‘length=3′incoercionto‘logical(l)’>TRUE&&c(T,F,F) ErrorinTRUE&c(T,F,F)>c(T,T,F) rnaTPIICTPIIC CAlI€C ‘”length=3″1incoercionto‘logical(1l)’ (i3CinadyQSearch = RunLTS =0 1Source~RScript¢ =0 %W—Ao&o‘o((f‘—- –oX R]Project:(None)~ EnvironmentHistoryConnectionsTutorial-] 2|[ImportDataset~‘3191MiB~!’List~– R~“}GlobalEnvironment~ values my_datanum[1:100]0.149NANANANA… my_divnum[1:3]3.483.182.15 my_nalogi[1:100]FALSETRUETRUETRUETRUETRUE… my_sqrtnum[1:3]0.3162.8281.463…
g_legend function – RDocumentation
library(ggplot2) library(gtable) library(grid) library(gridExtra) library(gtable) dsamp <- diamonds[sample(nrow(diamonds), 1000), ] (d <- ggplot(dsamp, aes(carat, price)) + geom_point(aes(colour = clarity)) + theme(legend.position=’bottom’)) legend <- g_legend(d) grid.newpage() grid.draw(legend) (d2 <- ggplot(dsamp, aes(x=carat, fill=clarity)) + geom_histogram(binwidth=0.1) + theme(legend.position=’bottom’)) grid.arrange(d + theme(legend.position=’hidden’), d2 + theme(legend.position=’hidden’), bottom=legend$grobs[[1]]) # Above fails with more than one guide…
count function – RDocumentation
# Count of each value of “id” in the first 100 cases count(baseball[1:100,], vars = “id”) # Count of ids, weighted by their “g” loading count(baseball[1:100,], vars = “id”, wt_var = “g”) count(baseball, “id”, “ab”) count(baseball, “lg”) # How many stints do players do? count(baseball, “stint”) # Count of times…
scater majlisalbarzakh
Bioconductor – scater Single-Cell Analysis Toolkit for Gene Expression Data in R. Bioconductor version: Release (3.17) A collection of tools for doing various analyses of single-cell RNA-seq gene expression data, with a focus on quality control and visualization. GitHub – jimhester/scater: Single cell analysis tools for… Feb 3, 2016 ·…
ggplot2 dragapie
Create Elegant Data Visualisations Using the Grammar of Graphics… Overview. ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details. Data visualization…
map_data function – RDocumentation
if (require(“maps”)) { states <- map_data(“state”) arrests <- USArrests names(arrests) <- tolower(names(arrests)) arrests$region <- tolower(rownames(USArrests)) choro <- merge(states, arrests, sort = FALSE, by = “region”) choro <- choro[order(choro$order), ] ggplot(choro, aes(long, lat)) + geom_polygon(aes(group = group, fill = assault)) + coord_map(“albers”, lat0 = 45.5, lat1 = 29.5) } if (require(“maps”))…
ggplot in r hirefunnel
Create Elegant Data Visualisations Using the Grammar of Graphics… R for Data Science is designed to give you a comprehensive introduction to the tidyverse, and these two chapters will get you up to speed with the essentials of ggplot2 as quickly as possible. If you’d like to take an online…
Normalization for microarrays >1000+ samples?
Normalization for microarrays >1000+ samples? 0 Hi all, I am trying to normalize microarray data starting from CEL files of 1000+ patients. It is The Affymetrix HTA 2.0 array. On my cluster it currently only works in about 350 patient batches, but the normalization doesn’t look good because it goes…
ggplot2 – Use map function to create multiple plots in R
I am interested in creating plots exploring a range of variables in columns within a dataframe. So far, I have a function that successfully calls a plot, and now hoping to apply this in a tidyverse format with map. require(dplyr) library(purrr) # create dataframe mydf <- data.frame(“category” = as.factor(sample(c(“type1”, “type2”),…
labkey.getLookupDetails function – RDocumentation
if (FALSE) { ## Details of fields of a query referenced by a lookup field # library(Rlabkey) lu1 <- labkey.getLookupDetails( baseUrl=”http://localhost:8080/labkey”, folderPath=”/apisamples”, schemaName=”lists”, queryName=”AllTypes”, lookupKey=”Category” ) lu1 ## When a lookup field points to a query object that itself has a lookup ## field, use a compound fieldkey consisting of…
Gene Set Comparison Without Expression Data
Gene Set Comparison Without Expression Data 1 I have been looking all over the web to find some answers to my problem but unfortunately, I was unsuccessful. I wish to determine whether an a priori defined set of genes in my case genes associated with Epidermolysis bullosa shows statistically significant,…
subplot function – RDocumentation
# pass any number of plotly objects to subplot() p1 <- plot_ly(economics, x = ~date, y = ~uempmed) p2 <- plot_ly(economics, x = ~date, y = ~unemploy) subplot(p1, p2, p1, p2, nrows = 2, margin = 0.05) #’ # anchor multiple traces on the same legend entry p1 <- add_lines(p1,…
read.GenBank function – RDocumentation
The function uses the site www.ncbi.nlm.nih.gov/ from where the sequences are retrieved. If species.names = TRUE, the returned list has an attribute “species” containing the names of the species taken from the field “ORGANISM” in GenBank. Since ape 3.6, this function retrieves the sequences in FASTA format: this is more…
element_textbox function – RDocumentation
Usage element_textbox( family = NULL, face = NULL, size = NULL, colour = NULL, fill = NULL, box.colour = NULL, linetype = NULL, linewidth = NULL, hjust = NULL, vjust = NULL, halign = NULL, valign = NULL, lineheight = NULL, margin = NULL, padding = NULL, width = NULL,…
restart function – RDocumentation
It is not possible to restart an R session running in RGui on Microsoft Windows using this function. It is not possible to restart an R session in the RStudio Console using this function. However, it does work when running R in the RStudio Terminal. RStudio provides rstudioapi::restartSession() which will…
scale_fill_viridis function – RDocumentation
library(ggplot2) # Ripped from the pages of ggplot2 p <- ggplot(mtcars, aes(wt, mpg)) p + geom_point(size = 4, aes(colour = factor(cyl))) + scale_color_viridis(discrete = TRUE) + theme_bw() # Ripped from the pages of ggplot2 dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y…
getRs function – RDocumentation
if (FALSE) { getRs() # list available scripts scripts <- getRs() # likewise, but store in an object that can easily # be viewed on demand in RStudio getRs(‘introda.r’) # download introda.r and put in script editor getRs(cats=TRUE) # list available major and minor categories categories <- getRs(cats=TRUE) # likewise…
geom_qq_line function – RDocumentation
Usage geom_qq_line( mapping = NULL, data = NULL, geom = “path”, position = “identity”, …, distribution = stats::qnorm, dparams = list(), line.p = c(0.25, 0.75), fullrange = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )stat_qq_line( mapping = NULL, data = NULL, geom = “path”, position = “identity”,…
annotate function – RDocumentation
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() p + annotate(“text”, x = 4, y = 25, label = “Some text”) p + annotate(“text”, x = 2:5, y = 25, label = “Some text”) p + annotate(“rect”, xmin = 3, xmax = 4.2, ymin = 12, ymax…
coord_polar function – RDocumentation
# NOTE: Use these plots with caution – polar coordinates has # major perceptual problems. The main point of these examples is # to demonstrate how these common plots can be described in the # grammar. Use with EXTREME caution. #’ # A pie chart = stacked bar chart +…
r shin :: testserver cat messages results
Summary Reactive testing for Shiny server functions and modules can be used to test the reactive interactions in Shiny applications. 1 This includes interactions defined in the server function of applications and in modules. 1 According to See more results on Neeva Summaries from the best pages on the web…
aes function – RDocumentation
aes(x = mpg, y = wt) aes(mpg, wt) # You can also map aesthetics to functions of variables aes(x = mpg ^ 2, y = wt / cyl) # Or to constants aes(x = 1, colour = “smooth”) # Aesthetic names are automatically standardised aes(col = x) aes(fg = x)…
scale_x_discrete function – RDocumentation
ggplot(diamonds, aes(cut)) + geom_bar() # \donttest{ # The discrete position scale is added automatically whenever you # have a discrete position. (d <- ggplot(subset(diamonds, carat > 1), aes(cut, clarity)) + geom_jitter()) d + scale_x_discrete(“Cut”) d + scale_x_discrete( “Cut”, labels = c( “Fair” = “F”, “Good” = “G”, “Very Good” =…
scale_color_d3 function – RDocumentation
library(“ggplot2”) data(“diamonds”) p1 <- ggplot( subset(diamonds, carat >= 2.2), aes(x = table, y = price, colour = cut) ) + geom_point(alpha = 0.7) + geom_smooth(method = “loess”, alpha = 0.1, size = 1, span = 1) + theme_bw() p2 <- ggplot( subset(diamonds, carat > 2.2 & depth > 55 &…
theme_nothing function – RDocumentation
# no legend example n <- 50 df <- expand.grid(x = 1:n,y = 1:n)[sample(n^2,.5*n^2),] p <- ggplot(df, aes(x, y)) + geom_raster() p p + theme_nothing() p + theme_nothing(legend = TRUE) # no difference p + scale_x_continuous(expand = c(0,0)) + scale_y_continuous(expand = c(0,0)) + theme_nothing() # legend example df$class <- factor(sample(0:1,…
ranef function – RDocumentation
library(lattice) ## for dotplot, qqmath fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy) fm3 <- lmer(diameter ~ (1|plate) + (1|sample), Penicillin) ranef(fm1) str(rr1 <- ranef(fm1)) dotplot(rr1) ## default qqmath(rr1) ## specify free scales in order to make Day effects more…
scale_colour_discrete function – RDocumentation
# Template function for creating densities grouped by a variable cty_by_var <- function(var) { ggplot(mpg, aes(cty, colour = factor({{var}}), fill = factor({{var}}))) + geom_density(alpha = 0.2) } # The default, scale_fill_hue(), is not colour-blind safe cty_by_var(class) # (Temporarily) set the default to Okabe-Ito (which is colour-blind safe) okabe <- c(“#E69F00”,…
BiocManager package – RDocumentation
Overview The BiocManager package, as the modern successor package to BiocInstaller, allows users to install and manage packages from the Bioconductor project. Bioconductor focuses on the statistical analysis and comprehension of high-throughput genomic data. Current Bioconductor packages are available on a ‘release’ version intended for every-day use, and a ‘devel’…
ymd_hms function – RDocumentation
ymd_hms( …, quiet = FALSE, tz = “UTC”, locale = Sys.getlocale(“LC_TIME”), truncated = 0 ) ymd_hm( …, quiet = FALSE, tz = “UTC”, locale = Sys.getlocale(“LC_TIME”), truncated = 0 ) ymd_h( …, quiet = FALSE, tz = “UTC”, locale = Sys.getlocale(“LC_TIME”), truncated = 0 ) dmy_hms( …, quiet = FALSE,…
labs function – RDocumentation
p <- ggplot(mtcars, aes(mpg, wt, colour = cyl)) + geom_point() p + labs(colour = “Cylinders”) p + labs(x = “New x label”) # The plot title appears at the top-left, with the subtitle # display in smaller text underneath it p + labs(title = “New plot title”) p + labs(title…
guides function – RDocumentation
# \donttest{ # ggplot object dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5), r = factor(1:5)) p <- ggplot(dat, aes(x, y, colour = p, size = q, shape = r)) + geom_point() # without guide specification p # Show colorbar guide for colour. #…
qplot function – RDocumentation
# Use data from data.frame qplot(mpg, wt, data = mtcars) qplot(mpg, wt, data = mtcars, colour = cyl) qplot(mpg, wt, data = mtcars, size = cyl) qplot(mpg, wt, data = mtcars, facets = vs ~ am) # \donttest{ set.seed(1) qplot(1:10, rnorm(10), colour = runif(10)) qplot(1:10, letters[1:10]) mod <- lm(mpg ~…
RSQLite package – RDocumentation
Embeds the SQLite database engine in R, providing a DBI-compliant interface. SQLite is a public-domain, single-user, very light-weight database engine that implements a decent subset of the SQL 92 standard, including the core table creation, updating, insertion, and selection operations, plus transaction management. You can install the latest released version…
ggplot2 package – RDocumentation
Aesthetics: grouping Given a character vector, create a set of identity mappings Automatic aesthetic mapping Modify properties of an element in a theme object Absolute grob Differentiation related aesthetics: linetype, size, shape Construct aesthetic mappings Colour related aesthetics: colour, fill, and alpha Control aesthetic evaluation Define aesthetic mappings programmatically Annotation:…
geom_path function – RDocumentation
# geom_line() is suitable for time series ggplot(economics, aes(date, unemploy)) + geom_line() ggplot(economics_long, aes(date, value01, colour = variable)) + geom_line() # You can get a timeseries that run vertically by setting the orientation ggplot(economics, aes(unemploy, date)) + geom_line(orientation = “y”) # geom_step() is useful when you want to highlight exactly…
prepare.ggplot.shap.data function – RDocumentation
Description Conforms to data format required for ggplot functions. Usage prepare.ggplot.shap.data(data_list, normalize = FALSE) Value A data.table containing the observation ID, the feature name, the feature value (normalized if specified), and the SHAP contribution value. Arguments data_list List containing ‘data’ and ‘shap_contrib’ returned by xgb.shap.data(). normalize Whether to standardize feature…
How to add gradient to ridgeplot? – ggplot2
2 January 2023 class #End result is same, only equation to get the result is a little different #ggplot(data = <DATA>) + <GEOM_FUNCTION>(mapping=aes(<MAPPING>)) #ggplot(data = <DATA>, mapping = aes(<MAPPINGS>)) + <GEOM_FUNCTION>() #ggplot(<DATA>, aes(<MAPPINGS>)) + <GEOM_FUNCTION>() #ggplot(<DATA>) + <GEOM_FUNCTION>(aes(<MAPPINGS)) #how to change library you are working in library(dplyr) #mpg dataset is…
labkey.experiment.saveRuns function – RDocumentation
Examples # NOT RUN { library(Rlabkey) ## example with materialInputs and materialOutputs m1 <- labkey.experiment.createMaterial( list(name = “87444063.2604.626”), sampleSetName = “Study Specimens”) m2 <- labkey.experiment.createMaterial( list(name = “87444063.2604.625”), sampleSetName = “Study Specimens”) run <- labkey.experiment.createRun( list(name=”new run”), materialInputs = m1, materialOutputs = m2) labkey.experiment.saveRuns(baseUrl=”http://labkey/”, folderPath=”home”, protocolName=labkey.experiment.SAMPLE_DERIVATION_PROTOCOL, runList=run) # } Run…
chromoMap function – RDocumentation
Usage chromoMap( ch.files, data.files, title = c(), ch_gap = 5, ploidy = 1, top_margin = 25, left_margin = 50, chr_width = 15, chr_length = 4, chr_color = c(“black”), data_based_color_map = FALSE, segment_annotation = FALSE, lg_x = 0, lg_y = 0, data_type = c(“numeric”, “categorical”), labels = FALSE, canvas_width = NULL,…
ggplot2loon function – RDocumentation
Examples # NOT RUN { if(interactive()) { p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() g <- ggplot2loon(p) p1 <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg, colour = factor(gear))) + facet_wrap(~am) g1 <- ggplot2loon(p1) # } # NOT RUN { df <- data.frame( x = rnorm(120, c(0, 2, 4)),…
multiRegression function – RDocumentation
Examples # NOT RUN { seed = 1234 N = 100 # sample size Ng = 5 # gene number Nk = 5 * 3 # eQTL number Ns = 1 # sparse ratio sigma2 = 0.01 # sigma2 set.seed(seed) data = randomFSSEMdata(n = N, p = Ng, k =…
labkey.provenance.stopRecording function – RDocumentation
Examples Run in Workspace # NOT RUN { library(Rlabkey) ## object inputs (from an assay run) and material inputs ## oi <- labkey.selectRows(baseUrl=”https://labkey.org/labkey/”, folderPath = “Provenance”, schemaName=”assay.General.titer”, queryName=”Data”, colSelect= c(“LSID”), colFilter=makeFilter(c(“Run/RowId”,”EQUAL”,”253″))) mi <- data.frame(lsid=c(“urn:lsid:labkey.com:Sample.251.MySamples:sample1″, “urn:lsid:labkey.com:Sample.251.MySamples:sample2″)) p <- labkey.provenance.createProvenanceParams(name=”step1″, description=”initial step”, objectInputs=oi[[“LSID”]], materialInputs=mi) r <- labkey.provenance.startRecording(baseUrl=”https://labkey.org/labkey/”, folderPath = “Provenance”, provenanceParams=p) run…
stri_trans_nfc function – RDocumentation
Unicode Normalization Forms are formally defined normalizations of Unicode strings which, e.g., make possible to determine whether any two strings are equivalent. Essentially, the Unicode Normalization Algorithm puts all combining marks in a specified order, and uses rules for decomposition and composition to transform each string into one of the…
sqliteCopyDatabase function – RDocumentation
Description Copies a database connection to a file or to another database connection. It can be used to save an in-memory database (created using dbname = “:memory:” or dbname = “file::memory:”) to a file or to create an in-memory database a copy of another database. Usage sqliteCopyDatabase(from, to) Arguments from…
h2o.explain function – RDocumentation
Description The H2O Explainability Interface is a convenient wrapper to a number of explainabilty methods and visualizations in H2O. The function can be applied to a single model or group of models and returns a list of explanations, which are individual units of explanation such as a partial dependence plot…
RunPCA function – RDocumentation
RunPCA(object, …) # S3 method for default RunPCA( object, assay = NULL, npcs = 50, rev.pca = FALSE, weight.by.var = TRUE, verbose = TRUE, ndims.print = 1:5, nfeatures.print = 30, reduction.key = “PC_”, seed.use = 42, approx = TRUE, … ) # S3 method for Assay RunPCA( object, assay =…
Adjust the legends distance to the x-axis?
ggplot2: Adjust the legends distance to the x-axis? I want to shrink the legends distance to the x-axis, but I can’t find a way to do it. Is it possible? Example code: library(ggplot2) ggplot(mtcars, aes(x = gear, y = mpg, fill = gear)) + geom_bar(stat = “identity”) + theme(legend.position =…
labkey.pipeline.getProtocols function – RDocumentation
Description Gets the protocols that have been saved for a particular pipeline. Usage labkey.pipeline.getProtocols(baseUrl=NULL, folderPath, taskId, path, includeWorkbooks = FALSE) Arguments baseUrl a string specifying the baseUrl for the LabKey server folderPath a string specifying the folderPath taskId a string identifier for the pipeline path a string for the relative…
labkey.webdav.delete function – RDocumentation
Description This will delete the supplied file or folder under the specified LabKey Server project using WebDAV. Usage labkey.webdav.delete( baseUrl=NULL, folderPath, remoteFilePath, fileSet=”@files” ) Arguments baseUrl a string specifying the baseUrl for the labkey server folderPath a string specifying the folderPath remoteFilePath the path to delete, relative to the LabKey…