locfunc not found in DESeq2
2
0
Entering edit mode
Hope ▴ 10
@993cf259
Last seen 6 weeks ago
United States

I am trying to use the locfunc="shorth" in the estimatesizeFactors function for DESeq2 but am getting the error that the locfunc function doesn't exist. I've only found similar errors for DESeq and those solutions don't work (median <- NULL or removing global variables). I also made sure that genefilter library was loaded since it's what is listed as connecting shorth and got the same error. Below, I list the code line that is the problem as well as the libraries I loaded. When I did not include locfunc="shorth" or manually put locfunc=stats::median, it works fine. Thank you so much in advance!

##############################
# PROBLEMATIC CODE # 
library(seqgendiff)
library(data.table)
library(stringr)
library(ggplot2)
library(DESeq2)
library(genefilter)
dds_bid_2rep_1000ft_rat_shorth = estimateSizeFactors(dds_bid_2rep_1000ft, type="ratio", locfunc="shorth")
# OUTPUT #
Error in locfunc((log(cnts) - loggeomeans)[is.finite(loggeomeans) & cnts > : could not find function "locfunc"
Traceback:

1. estimateSizeFactors(dds_bid_2rep_1000ft, type = "ratio", locfunc = "shorth")
2. estimateSizeFactors(dds_bid_2rep_1000ft, type = "ratio", locfunc = "shorth")
3. .local(object, ...)
4. estimateSizeFactorsForMatrix(counts(object), locfunc = locfunc, 
 .     geoMeans = geoMeans, controlGenes = controlGenes)
5. apply(counts, 2, function(cnts) {
 .     exp(locfunc((log(cnts) - loggeomeans)[is.finite(loggeomeans) & 
 .         cnts > 0]))
 . })
6. FUN(newX[, i], ...)
################################
# WHEN TRY TO FIND FUNCTION #
library(sos)
findFn("locfunc") has output "found 0 matches"
?locfunc & ??locfunc can't find anything

# please also include the results of running the following in an R session 
sessionInfo( )

R version 4.3.0 (2023-04-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Matrix products: default
BLAS/LAPACK: /Users/hopekirby/miniconda3/envs/r-kernel/lib/libopenblasp-r0.3.23.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Denver
tzcode source: system (macOS)

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] genefilter_1.82.1           DESeq2_1.40.2              
 [3] SummarizedExperiment_1.30.2 Biobase_2.60.0             
 [5] MatrixGenerics_1.12.2       matrixStats_1.0.0          
 [7] GenomicRanges_1.52.0        GenomeInfoDb_1.36.1        
 [9] IRanges_2.34.1              S4Vectors_0.38.1           
[11] BiocGenerics_0.46.0         cowplot_1.1.1              
[13] ggplot2_3.4.3               stringr_1.5.0              
[15] data.table_1.14.8           seqgendiff_1.2.3           

loaded via a namespace (and not attached):
 [1] KEGGREST_1.40.0         gtable_0.3.4            lattice_0.21-8         
 [4] vctrs_0.6.3             tools_4.3.0             bitops_1.0-7           
 [7] generics_0.1.3          parallel_4.3.0          RSQLite_2.3.1          
[10] AnnotationDbi_1.62.2    tibble_3.2.1            fansi_1.0.4            
[13] blob_1.2.4              pkgconfig_2.0.3         Matrix_1.5-4.1         
[16] assertthat_0.2.1        uuid_1.1-0              lifecycle_1.0.3        
[19] GenomeInfoDbData_1.2.10 compiler_4.3.0          Biostrings_2.68.1      
[22] munsell_0.5.0           repr_1.1.6              codetools_0.2-19       
[25] htmltools_0.5.5         RCurl_1.98-1.12         pillar_1.9.0           
[28] crayon_1.5.2            BiocParallel_1.34.2     cachem_1.0.8           
[31] DelayedArray_0.26.7     abind_1.4-5             tidyselect_1.2.0       
[34] locfit_1.5-9.8          digest_0.6.33           stringi_1.7.12         
[37] dplyr_1.1.2             splines_4.3.0           fastmap_1.1.1          
[40] grid_4.3.0              colorspace_2.1-0        cli_3.6.1              
[43] magrittr_2.0.3          S4Arrays_1.0.5          base64enc_0.1-3        
[46] survival_3.5-5          XML_3.99-0.14           utf8_1.2.3             
[49] IRdisplay_1.1           withr_2.5.0             scales_1.2.1           
[52] bit64_4.0.5             IRkernel_1.3.2          XVector_0.40.0         
[55] httr_1.4.6              bit_4.0.5               pbdZMQ_0.3-9           
[58] png_0.1-8               memoise_2.0.1           evaluate_0.21          
[61] rlang_1.1.1             Rcpp_1.0.11             DBI_1.1.3              
[64] xtable_1.8-4            glue_1.6.2              annotate_1.78.0        
[67] jsonlite_1.8.7          R6_2.5.1                zlibbioc_1.46.0
locfunc DESeq2 shorth estimateSizeFactors • 298 views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 18 hours ago
United States

The argument for locfunc is meant to be a function, not a character vector. You should instead use locfunc = genefilter::shorth.

1
Entering edit mode
Hope ▴ 10
@993cf259
Last seen 6 weeks ago
United States

Thank you James! Here's an example of how the function should be implemented if others get confused haha. The locfunc is a variable that you assign to a FUNCTION. Therefore, if you want to use shorth, you use the function shorth (or genefilter::shorth) NOT a string "shorth". Example implementation of my code is below:

dds_bid_2rep_1000ft_rat_shorth = estimateSizeFactors(dds_bid_2rep_1000ft, type="ratio", locfunc=genefilter::shorth)
OR
dds_bid_2rep_1000ft_rat_shorth = estimateSizeFactors(dds_bid_2rep_1000ft, type="ratio", locfunc=shorth)
ADD COMMENT

Login before adding your answer.

Traffic: 573 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6