This file contains hidden or 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(DelayedArray) | |
| setClass("plBedSeed", | |
| contains="Array", | |
| slots = c( | |
| dim = "integer", | |
| bedreaderRef = "ANY", | |
| dimnames = "list" | |
| ) | |
| ) |
This file contains hidden or 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
| make1zip = function(pname, target="zips322") { | |
| if (!dir.exists(target)) dir.create(target) | |
| target = file.path(getwd(), target) | |
| ins = try(BiocManager::install(pname, ask=FALSE, update=FALSE, type="binary", | |
| dependencies=TRUE, force=TRUE)) # acquire dependencies as needed | |
| if (inherits(ins, "try-error")) stop(sprintf("can't install %s with BiocManager", pname)) | |
| #real_inst = try(install.packages(pname, type="source", repos=NULL)) # this uses native windows build tools from Rtools | |
| bpath = pkgbuild::build(pname) | |
| if (inherits(bpath, "try-error")) stop(sprintf("can't build %s from source", pname)) | |
| install.packages(bpath, type="source", repos=NULL) |
This file contains hidden or 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(BiocPkgTools) | |
| all322 = biocPkgList(version="3.22", repo="BioCsoft")$Package | |
| library(BiocBuildTools) # from github vjcitn | |
| set322=PackageSet(all322, biocversion="3.22", branchname="RELEASE_3_22") | |
| dir.create("srcs_322") | |
| populate_local_gits(set322, gitspath="srcs_322") |
This file contains hidden or 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
| from owlready2 import get_ontology, onto_path, sync_reasoner | |
| def find_terms_by_keyword(ontology, keyword): | |
| # Simple case: search class labels and names | |
| results = [] | |
| for cls in ontology.classes(): | |
| label = cls.label.first() if hasattr(cls, "label") and cls.label else cls.name | |
| if keyword.lower() in label.lower(): | |
| results.append(cls) | |
| return results |
This file contains hidden or 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
| from owlready2 import get_ontology, onto_path | |
| import numpy as np | |
| def term_to_class(user_term, onto): | |
| all_terms = list(onto.classes()) | |
| excluded_terms = get_excluded_terms(onto) | |
| # Try to find by label first, then by name | |
| found = None | |
| for cls in all_terms: | |
| if cls in excluded_terms: |
This file contains hidden or 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(SummarizedExperiment) | |
| library(irlba) | |
| ibiplot = function(se, choices=1:2, nfeat=5, ircomp=6, ...) { | |
| dat = t(assay(se)) | |
| pcs = prcomp_irlba(dat, ircomp) | |
| rot = pcs$rotation | |
| ss = rowSums(abs(rot[,choices])^2) | |
| kp = order(ss, decreasing=TRUE)[seq_len(nfeat)] | |
| labs = rep(" ", nrow(rot)) | |
| labs[kp] = rownames(se)[kp] |
This file contains hidden or 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(S4Vectors) | |
| library(SummarizedExperiment) | |
| library(GDSArray) | |
| library(bigmelon) | |
| data(melon) | |
| tf = tempfile() | |
| es2gds(melon, tf) | |
| bm2SE = function(gdsf, elem="betas", | |
| fdkeep=c("ProbeID_A", "ProbeID_B", "ILMNID", "NAME", |
This file contains hidden or 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
| # based on https://alisterburt.com/napari-workshops/notebooks/viewer_intro.html | |
| library(reticulate) | |
| py_require("napari[all]") | |
| py_require("scikit-image") | |
| nap = import("napari") | |
| v = nap$Viewer() | |
| si = import("skimage") | |
| #id = si$data$cells3d() | |
| if (!file.exists("nuclei.tif")) { | |
| system("wget --no-check-certificate https://raw.githubusercontent.com/alisterburt/napari-workshops/main/napari-workshops/notebooks/data/nuclei.tif") |
This file contains hidden or 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(cropcircles) | |
| library(magick) | |
| y = image_read("owl.jpg") # https://commons.wikimedia.org/wiki/File:Great_Horned_Owl_(30706490070).jpg | |
| library(cropcircles) | |
| img_cropped_path <- hex_crop( | |
| images = "owl.jpg", | |
| border_colour = "#107e54", | |
| border_size = 24 | |
| ) |
This file contains hidden or 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
| # reference for managing BLAS usage -- https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Which-BLAS-is-used-and-how-can-it-be-changed_003f-1 | |
| # script | |
| print(extSoftVersion()["BLAS"]) | |
| # global matrix value | |
| set.seed(1234) | |
| x = rnorm(500) | |
| y = x %*% t(x) | |
| # compute svd |
NewerOlder