Code Monkey home page Code Monkey logo

finemapr's Introduction

finemapr

travis-ci build status

R interface to fine-mappers:

By using finemapr, your input files are automatically prepared for each tool, the analysis workflow is tool-independent; and exploration of fine-mapping results is powered by R in printing/plotting/data export.

Note: the package is still under development and its current version is not stable. The current work aims at switching from run_<tool> functions to a more general one, finemapr. The later function makes use of S3 method dispatch features. Thus, use this package with caution until the stable release comes out.

Quick start

library(finemapr)
library(tidyverse)

# get some example data
finemapr::example_finemap() %>% attach

# run finemapping, default tool is finemap
out <- finemapr(z1, ld1, n1, args = "--n-causal-max 3")

# print & plot results
out

plot(out, grid_nrow = 1)

Tool-independent analysis workflow

# set up
options(finemapr_<tool> = "<path to fine-mapping tool>")

# read input files
my_zscores <- read_zscores("<my_scores.tab>")
my_ld <- read_ld("<my_ld.tab>")

# run analysis
# depreciated, but still works: out <- run_<tool>(my_zscores, my_ld, args = "<custom arguments>")
out <- finemapr(my_zscores, my_ld, method = "<tool>", args = "<custom arguments>")

# explore results
print(out)
head(out$snp) # main table of results
plot(out)

# export results
write.table(out$snp, "<my_results.tab>")

Examples

See the vignette Fine-mapping analysis pipeline by finemapr.

Related projects

finemapr's People

Contributors

dmitryprok avatar variani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

finemapr's Issues

Installation issue

Thanks for making this package. There seems to be an installation issue:

> devtools::install_github("variani/finemapr")
Downloading GitHub repo variani/finemapr@master
Installing 1 packages: cowplot
trying URL 'https://www.stats.bris.ac.uk/R/bin/macosx/el-capitan/contrib/3.6/cowplot_1.0.0.tgz'
Content type 'application/x-gzip' length 1362732 bytes (1.3 MB)
==================================================
downloaded 1.3 MB


The downloaded binary packages are in
	/var/folders/8t/4mzsfqzd5773rsc11w4q5fhw0000gp/T//RtmpLGywNM/downloaded_packages
   checking for file ‘/private/var/folders/8t/4mzsfqzd5773rsc11w4q5fhw0000gp/T/RtmpLGywNM/remotesb21825be3ea7/variani-finemapr-78d5d2f/✔  checking for file ‘/private/var/folders/8t/4mzsfqzd5773rsc11w4q5fhw0000gp/T/RtmpLGywNM/remotesb21825be3ea7/variani-finemapr-78d5d2f/DESCRIPTION’
─  preparing ‘finemapr’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘finemapr/misc’
─  building ‘finemapr_0.1.0.tar.gz’

* installing *source* package ‘finemapr’ ...
** using staged installation
** R
Error in .install_package_code_files(".", instdir) :
files in '/private/var/folders/8t/4mzsfqzd5773rsc11w4q5fhw0000gp/T/Rtmpp7Y6qx/R.INSTALLb48113ddeeda/finemapr/R' missing from 'Collate' field:
  abf.R
  cojo.R
  utils.R
ERROR: unable to collate and parse R files for package ‘finemapr’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/finemapr’
Error: Failed to install 'finemapr' from GitHub:
  (converted from warning) installation of package ‘/var/folders/8t/4mzsfqzd5773rsc11w4q5fhw0000gp/T//RtmpLGywNM/fileb2184f88b264/finemapr_0.1.0.tar.gz’ had non-zero exit status

I tried cloning, and document() and install() but still no luck. Any suggestions?

Update run_finemap.R for Finemap Version 1.3?

Hi @variani thank you for creating this package! I've found it really helpful for my summer internship project.

I'm currently working with the run_finemap function. I'm using Finemap version 1.3.1 for Mac OS X, but not with Finemap version 1.1. The errors make sense based on the documention for Finemap 1.3. I've noticed the following changes can be made to update it:

First, the master file for FINEMAP 1.3.1 needs to have columns with the following headings: z;ld;snp;config;cred;[prior-k if applicable];log;n_samples

Second, the z-file for Finemap 1.3.1 has to be 8 columns, unlike the 2 provided in the example. In R, I could modify the example z1 file as the following, using the input z-file documentation for FINEMAP:

z1 <- data.table(z1$snp, 1, 1:5363, "A", "G", 0, z1$zscore, 0)
colnames(z1)[1:8] <- c("snp", "chromosome", "position", "allele1", "allele2", "maf", "zscore", "se")

However, the third issue I have not been able to resolve. Even after I've updated the finemap.R function to address the extra columns, I get this error when I try to run the example with the updated z-file:
Error : Expected 'rsid' in line 1 column 1 of file 'region.z'!

I also updated finemapr to use the "rsid" column name for "snp", but this didn't resolve the issue.

Do you know what the issue could be? I've made a pull request so you can see the comparisons between the code.

Issue with printing out_finemap

I am working from the example code for FINEMAP in Finemap 1.1. However, when I try to print out_finemap:

out_finemap <- run_finemap(z1, ld1, n1, args = "--n-causal-snps 3") # if not using test, make it z1
print(out_finemap)
plot(out_finemap, label_size = 3, grid_ncol = 1)

I get the following error:
Error in seq.default(1, x$num_loci) : 'to' must be of length 1

It seems that out_finemap does not have a num_loci property, nor many of the properties mentioned within the FinemaprFinemap print function, including snps_finemap, snps_missing_finemap, snps_zscore, etc. Enclosed is a picture:

image

Could you help me figure out what my issue might be?

Prior K parameter for FINEMAP

Hi @variani great work with the finemapr package!

I'm currently looking at the run_finemap function. I'm wondering if it is possible to add in the prior K parameter for FINEMAP, and set it to default when not specified? Thanks!

ABF

Consider adding Approximate Bayes Factor. See example script.
abf.R.txt

Objects listed as exports, but not present in namespace:

Hello,

I installed your software via:

devtools::install_github("variani/finemapr")

When I loaded it I got this:

library(finemapr)
Warning message:
replacing previous import ‘Matrix::head’ by ‘utils::head’ when loading ‘finemapr’

When I tried to do:

load_all("~/R/x86_64-pc-linux-gnu-library/3.6/finemapr")

Loading finemapr
Skipping missing files: package.R, names.R, sumstats.R, abf.R, cojo.R, utils.R, read.R, datasets.R, files.R, plots.R, finemap.R, caviar.R, paintor.R, classMethods.R, classFinemaprPaintor.R, classFinemaprFinemap.R, classFinemaprCaviar.R, finemapr.R, ld.R, zzz.R
Warning messages:
1: replacing previous import ‘Matrix::head’ by ‘utils::head’ when loading ‘finemapr’
2: S3 methods ‘collect_results.FinemaprFinemap’, ‘collect_results.FinemaprPaintor’, ‘extract_credible_set.Finemapr’, ‘filename_annot.FinemaprPaintor’, ‘filename_config.FinemaprFinemap’, ‘filename_k.FinemaprFinemap’, ‘filename_ld.FinemaprFinemap’, ‘filename_ld.FinemaprPaintor’, ‘filename_log.FinemaprFinemap’, ‘filename_master.FinemaprFinemap’, ‘filename_master.FinemaprPaintor’, ‘filename_snp.FinemaprFinemap’, ‘filename_snp.FinemaprPaintor’, ‘filename_zscore.FinemaprFinemap’, ‘filename_zscore.FinemaprPaintor’, ‘plot.Finemapr’, ‘plot.FinemaprCaviar’, ‘plot.FinemaprFinemap’, ‘plot_config.FinemaprFinemap’, ‘plot_ncausal.FinemaprFinemap’, ‘plot_snp.Finemapr’, ‘plot_snp.FinemaprCaviar’, ‘plot_snp.FinemaprFinemap’, ‘plot_zscore.Finemapr’, ‘process_annot.FinemaprPaintor’, ‘process_ld.Finemapr’, ‘process_tab.Finemapr’, ‘run_tool.FinemaprFinemap’, ‘run_tool.FinemaprPaintor’, ‘write_f [... truncated]
3: In setup_ns_exports(path, export_all, export_imports) :
Objects listed as exports, but not present in namespace: cojo, collect_results, example_finemap, extract_credible_set, filename_annot, filename_config, filename_k, filename_ld, filename_log, filename_master, filename_snp, filename_zscore, finemapr, plot_config, plot_ncausal, plot_snp, plot_zscore, print.Finemapr, print.FinemaprCaviar, print.FinemaprFinemap, print.FinemaprPaintor, process_annot, process_ld, process_n, process_tab, proxysnps_ref_ld, proxysnps_ref_vcf, read_ld, read_zscore, ref_bed, ref_ld, ref_pop, run_caviar, run_finemap, run_paintor, run_tool, sumstats_bmi, write_files

And following your example here:

file1_z <- system.file("extdata/region1.z", package = "finemapr")
file1_ld <- system.file("extdata/region1.ld", package = "finemapr")

z1 <- read_zscore(file1_z)
Error in read_zscore(file1_z) : could not find function "read_zscore"

Can you please advise,
Thanks
Ana

NAMESPACE problem

you import ggrepel in NAMESPACE but it is not noted in DESCRIPTION

Number of causal SNPs

Hello and thank you for your tool!

Could you please explain, how the number of causal SNPs for FINEMAP is chosen in your implementation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.