Skip to content

Instantly share code, notes, and snippets.

View MVesuviusC's full-sized avatar

Matt Cannon MVesuviusC

View GitHub Profile
@MVesuviusC
MVesuviusC / r_package_error.txt
Last active March 5, 2024 14:03
R package install error
from: https://researchcomputing.princeton.edu/support/knowledge-base/rrstudio
9. How can I solve the following error?
Installing package into ‘/home/ceisgrub/R/x86_64-redhat-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") :
[tcl] grab failed: window not viewable.
R is trying to display a list of mirrors via X11 forwarding so try unsetting DISPLAY before starting R:
@MVesuviusC
MVesuviusC / slurm.txt
Created December 20, 2023 13:19
slurm stuff
function sacctRun() {
sacct --format="user,jobid,jobname,node,state,ExitCode,start,end,maxrss" \
| grep -v "COMPLETE\|FAIL\|CANCEL\|OUT_OF_ME" \
| awk '$2 != "batch" && $2 != "extern" {print}'
}
get_maint_time () {
maint_start=$(scontrol show -u root reservation \
| perl -pe 's/\n/#/g' \
| perl -pe 's/#ReservationName=/\n/g' \
@MVesuviusC
MVesuviusC / windows_md5.txt
Created December 1, 2023 15:07
calculate md5sum on windows
# open powershell
Get-FileHash file_here.txt -Algorithm MD5
@MVesuviusC
MVesuviusC / log_bash.txt
Created November 21, 2023 16:43
log bash inputs/outputs
# record command line inputs/outputs
script logfile.txt
# type stuff
exit
## Log is saved in logfile.txt
#capture groups
sed \
-E 's/.+(GA.+CA).+/stuff_\1_stuff/' \
/reference/homo_sapiens/hg19/ucsc_assembly/illumina_download/Sequence/WholeGenomeFasta/genome.fa \
| head
@MVesuviusC
MVesuviusC / checkBamFormat.txt
Created August 22, 2023 13:22
Check if a bam file format is valid
ml picard/2.21.6-Java-11.0.2
java -jar \
$EBROOTPICARD/picard.jar \
ValidateSamFile \
I=/gpfs0/scratch/mvc002/testTwoTumors/split_sams_2//S0149_1.sam \
MODE=VERBOSE
# Can optionally include ignore arguments to ignore specific error types
IGNORE=MISSING_TAG_NM \
@MVesuviusC
MVesuviusC / mclapply_try_errors.txt
Created August 18, 2023 20:08
Deal with try-errors in mclapply and get warning message
test <- parallel::mclapply(as.list(0:5), function(x) {
print(x)
if (x == 0) {
stop("something didn't work for ", x)
}
return(1)
})
if (any(lapply(test, function(x) class(x) == "try-error") |> unlist())) {
If you get the error about [error] Barcode out of bounds during cellranger mkfastq:
Have to run bcl2fastq directly like I did in R0063
https://kb.10xgenomics.com/hc/en-us/articles/360038857411--error-Barcode-out-of-bounds-I1-0-14-or-I2-0-16-
@MVesuviusC
MVesuviusC / gist:eaac41b8d2c73a2b50e24b5bdd41af65
Created May 23, 2023 19:57
Help vscode with X11 on windows machines
Create new account environment variable on your windows machine named DISPLAY with value of localhost:0.0
Make sure mobaxterm is running (or whatever X11 you want)
In your "Configure SSH Hosts" menu, put this under each Host:
ForwardX11 yes
ForwardX11Trusted yes
@MVesuviusC
MVesuviusC / cmp_seurat_object_commands.R
Last active May 23, 2023 13:47
Compare the commands run to generate two seurat objects
# compare the contents of the commands slot between test and combined_data
cmp_seurat_cmds <- function(sobj_a,
sobj_b,
sobj_a_name = "sobj_a",
sobj_b_name = "sobj_b",
verbose = FALSE) {
# Making a list here as not all of the contents of the arguments fit into a tibble
# A list can accept any data type
diff_list <- list()
for (step_ran in names(sobj_a@commands)) {