Package 'LDWeaver'

Title: Genomewide Epistasis Analysis on Bacteria
Description: Perform genomewide epistasis analysis by evaluating the LD structure in bacteria.
Authors: Sudaraka Mallawaarachchi [aut, cre]
Maintainer: Sudaraka Mallawaarachchi <[email protected]>
License: GPL (>=3) + file LICENSE
Version: 1.5.2
Built: 2026-09-19 09:24:31 UTC
Source: https://github.com/Sudaraka88/LDWeaver

Help Index


._legendfun2

Description

._legendfun2

Usage

._legendfun2(
  legend = c("Group A", "Group B"),
  lwd = 3,
  cex = 1.1,
  col = c("red", "blue"),
  ...
)

Arguments

legend

legend

lwd

lwd

cex

cex

col

col

...

...


.mat

Description

.mat

Usage

.mat(n, r)

Arguments

n

number of dimensions

r

reduction factor

Value

kernel reduction

Examples

## Not run: 
.mat(10, 5)

## End(Not run)

.rescale01

Description

.rescale01

Usage

.rescale01(v)

Arguments

v

vector to rescale between 0-1

Value

rescaled vector

Examples

## Not run: 
.rescale01(sample(10,25,10))

## End(Not run)

cleanup

Description

Function to clean up the files in <dset> folder, this will organise the saved files in to a more sensible folder structure. If clean up was performed already, nothing will be changed.

Usage

cleanup(dset, delete_after_moving = F)

Arguments

dset

<dset> folder that requires cleanup.

delete_after_moving

specify whether the organised files should be deleted from the original location (default = F). If False, all organised files will be moved to a directory called OLD

Examples

## Not run: 
gff3_path = "<path_to_gff3_annotation"
gff = read_GFF3_Annotation(gff3_path)

## End(Not run)

cleanup_support

Description

File operations for the cleanup function

Usage

cleanup_support(files, fldr)

Arguments

files

files to copy <from>

fldr

folder to copy <to>

Value

parsed annotation file in list format

Examples

## Not run: 
gff3_path = "<path_to_gff3_annotation"
gff = read_GFF3_Annotation(gff3_path)

## End(Not run)

create_network

Description

Function to generate a network view of top GWES hits

Usage

create_network(
  tophits,
  netplot_path = NULL,
  plot_title = NULL,
  separator = ":",
  max_plot_nodes = NULL,
  plot_w = 6000,
  plot_h = 4000,
  min_links_to_include = 2
)

Arguments

tophits

data frame with top short or long range GWES links, returned from LDWeaver::perform_snpEff_annotations()

netplot_path

folder to save the network (default = NULL, return ggplot object)

plot_title

title for the network plot (default = NULL)

separator

break pattern in annotation (default = ":", this is the default used by SnpEff)

max_plot_nodes

specify the maximum number of nodes to visualise in the plot (default = NULL, use all). Large values will result in a cluttered output, consider increasing plot size.

plot_w

specify plot width in pixels (default = 6000)

plot_h

specify plot height in pixels (default = 4000)

min_links_to_include

specify the minimum number of links required to retain the node in the plot (default = 2)

Value

Network plots (ggplot object)

Examples

## Not run: 
create_network(tophits, netplot_path)

## End(Not run)

create_network_for_gene

Description

Function to generate a network view of GWES hits for a given gene

Usage

create_network_for_gene(
  gene_name,
  sr_annotated_path = NULL,
  lr_annotated_path = NULL,
  drop_syXsy = T,
  drop_indirect = T,
  level = 1,
  separator = ":",
  min_links_to_include = 3
)

Arguments

gene_name

case sensitive name of genome region (must match the SnpEff annotated name)

sr_annotated_path

path to short-range annotated links tsv file (default = NULL)

lr_annotated_path

path to long-range annotated links tsv file (default = NULL)

drop_syXsy

specify whether to drop synonymous-synonymous links (default = T)

drop_indirect

specify whether to drop ARACNE indirect links (default = T)

level

set 1 for only nearest neighbours, set 2 for an additional layer (default = 1)

separator

break pattern in annotation (default = ":", this is the default used by SnpEff)

min_links_to_include

specify the minimum number of links required to retain the node in the plot (default = 3)

Value

data_frame to use as input for LDWeaver::create_network()

Examples

## Not run: 
create_network_for_gene(tophits, netplot_path)

## End(Not run)

create_tanglegram

Description

Function to generate long and short range GWES plots

Usage

create_tanglegram(
  tophits,
  gbk = NULL,
  gff = NULL,
  tanglegram_folder,
  break_segments = 5,
  links_type = "SR"
)

Arguments

tophits

data frame with top short range GWES links, returned from LDWeaver::perform_snpEff_annotations()

gbk

output from parsing the genbank file using LDWeaver::parse_genbank_file() (default = NULL), only provide either GFF3 or GBK annotation

gff

output from parsing the gff3 file using LDWeaver::parse_gff_file() (default = NULL), only provide either GFF3 or GBK annotation

tanglegram_folder

folder to save tanglegram(s)

break_segments

specify the number of genome segments to prepare - one tanglegram per segment (default = 5)

links_type

specify the links type long-range "LR" or short-range "SR" (default = "SR"). A tanglegram may not be suitable to visualise long range links!

Value

none

Examples

## Not run: 
gbk = LDWeaver::parse_genbank_file("path_to_genbank_file", length_check = F)
create_tanglegram(tophits, gbk, "save_folder")

## End(Not run)

estimate_Hamming_distance_weights

Description

Function to estimate the similarity between sequences based on the Hamming distance

Usage

estimate_Hamming_distance_weights(snp.dat, threshold = 0.1, mega_dset = F)

Arguments

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment()

threshold

Hamming distance similarity threshold (default = 0.1, i.e. 10%)

mega_dset

set to TRUE for mega scale datasets (default = F)

Value

Vector with Hamming distance weights for each sequence that can be used to reweight Mutual Information estimates

Examples

## Not run: 
hdw <- estimate_Hamming_distance_weights(snp.dat, threshold=0.1)

## End(Not run)

estimate_variation_in_CDS

Description

Function to estimate the variation within each coding region, the output from this function can be used to segment the genome into diversity-based clusters.

Usage

estimate_variation_in_CDS(
  snp.dat,
  ncores,
  gbk = NULL,
  gff = NULL,
  num_clusts_CDS = 3,
  clust_plt_path = NULL,
  mega_dset = FALSE
)

Arguments

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment()

ncores

specify the number of cores to use

gbk

output from parsing the genbank file using LDWeaver::parse_genbank_file()

gff

output from parsing the gff3 file using LDWeaver::parse_gff_file()

num_clusts_CDS

parition to genome into num_clusts_CDS regions using k-means (default = 3)

clust_plt_path

specify path to save CDS variation plot

mega_dset

set to TRUE for mega scale datasets (default = F)

Value

R list with CDS variation and allele distribution details

Examples

## Not run: 
cds_var <- estimate_variation_in_CDS(gbk, snp.dat, ncores = 10)

## End(Not run)

GBAccession ID class

Description

A class representing the (versioned) GenBank accession

Usage

GBAccession(id)

Arguments

id

A versioned GenBank Accession id

Value

a GBAccession object.


GenBank File

Description

A resource class for use within the rtracklayer framework


GenBank data objects.

Description

These objects represent GenBank annotations


genomewide_LDMap

Description

Function to generate the bird's-eye view of the genomewide LD structure (measured as weighted-MI)

Usage

genomewide_LDMap(
  lr_links_path,
  sr_links_path,
  plot_save_path,
  reducer = NULL,
  plot_title = NULL,
  links_from_spydrpick = F,
  from = NULL,
  to = NULL
)

Arguments

lr_links_path

path to saved <lr_links.tsv> or spydrpick edges (links) file

sr_links_path

path to saved SR links, generally called <sr_links.tsv>

plot_save_path

path to save the LD Map

reducer

positive value used to reduce the LDMap size (default = NULL, will use length(positions)/1e3). The default paramter should work well, reducing the parameter will increase resolution at the cost of resources.

plot_title

title for the LD Map (default = NULL)

links_from_spydrpick

are the links computed using spydrpick (default = F)

from

draw the plot within the region starting <from> (default = NULL)

to

draw the plot within the region ending in <to> (default = NULL)

Examples

## Not run: 
genomewide_LDMap(lr_links_path, sr_links_path, plot_save_path)

## End(Not run)

LDWeaver

Description

Function to run the LDWeaver pipeline

Usage

LDWeaver(
  dset,
  aln_path,
  aln_has_all_bases = T,
  pos = NULL,
  gbk_path = NULL,
  gff3_path = NULL,
  ref_fasta_path = NULL,
  validate_ref_ann_lengths = T,
  snp_filt_method = "default",
  gap_freq = 0.15,
  maf_freq = 0.01,
  hdw_threshold = 0.1,
  perform_SR_analysis_only = F,
  SnpEff_Annotate = T,
  sr_dist = 20000,
  lr_retain_links = 1e+06,
  max_tophits = 250,
  num_clusts_CDS = 3,
  srp_cutoff = 3,
  tanglegram_break_segments = 5,
  write_gwesExplorer = T,
  multicore = T,
  max_blk_sz = 10000,
  ncores = NULL,
  save_additional_outputs = F,
  mega_dset = F
)

Arguments

dset

name of the dataset, all outputs will be saved to the folder <dset>

aln_path

path to the multi fasta alignment - can be a SNP only or full alignment

aln_has_all_bases

specify whether the alignment has all bases in the reference genome (default = T). For a SNP only alignment, set to F and provide SNP positions in pos (see example below)

pos

numeric vector of positions for each base in the alignment (default = NULL). Only required for SNP alignments (e.g. Output from snp-sites or FastaR https://github.com/Sudaraka88/FastaR)

gbk_path

path to genbank annotations file (default = NULL). Only provide one of genbank or gff3

gff3_path

path to gff3 annotations file (default = NULL). Only provide one of genbank or gff3

ref_fasta_path

path to Reference fasta file. This must be in fasta format and contain exactly one sequence! Only required for gff3 annotations

validate_ref_ann_lengths

check if the reference sequence length matches with fasta alignment. (default = T for full alignments, = F for snp-only alignments.). Set to F for alignments that only contain a portion of the genome

snp_filt_method

specify SNP filtering method: 'relaxed' or 'default' (default = 'default'). Unlike default, relaxed considers ambiguous/gap characters (N) as minor alleles when applying the maf_freq filter. Eg: Under default filter values, a site with allele frequencies A:0.85, C:0.0095, N:0.1405 will be respectively, dropped and allowed by 'default' and 'relaxed'

gap_freq

sites with a gap frequency >gap_greq will be dropped (default = 0.15)

maf_freq

sites with a minor allele frequency <maf_freq will be dropped (default = 0.01)

hdw_threshold

Hamming distance similarity threshold (default = 0.1, i.e. 10%) - lower values will force stricter population structure control at the cost of masking real signal

perform_SR_analysis_only

specify whether to only perform LDWeaver (short-range link) analysis. (default = FALSE) will analyse all links (i.e., LDWeaver + SpydrPick)

SnpEff_Annotate

specify whether to perform annotations using SnpEff (default = TRUE)

sr_dist

links shorter than <sr_dist> apart are considered 'short range' (default = 20000), range 1000 - 25000 bp

lr_retain_links

specify the maximum number of long-range MI links to retain (default = 1000000) - in each block, only a top subset of links will be saved such approximately this many links will be retained

max_tophits

specify the maximum number of short range links to save as <sr_tophits.tsv>. Note: all short-range links will be annotated (and saved separately), but only the top <max_tophits> will be used for visualisation (default = 250), range 50 - 1000

num_clusts_CDS

partition to genome into num_clusts_CDS regions using k-means (default = 3) range 1 - 10 - accounts for within genome heterogeneity in the short-range analysis

srp_cutoff

specify the short-range -log10(p) cut-off value to discard short-range links before returning the data.frame (default = 3, i.e., p = 10^-3). This setting has no impact on modelling since all links are used. Larger values will reduce memory usage, plotting time and ARACNE run time. If all links are required, set to 0 (i.e. p = 10^0 = 1), range 0 - 5

tanglegram_break_segments

specify the number of genome tanglegram segments to prepare (default = 5 segments). Set NULL to skip tanglegram. range 1 - 10.

write_gwesExplorer

specify whether to write output for GWESExplorer (default = T)

multicore

specify whether to use parallel processing (default = T)

max_blk_sz

specify maximum block size for MI computation (default = 10000), larger sizes require more RAM, range 1000 - 100000

ncores

specify the number of cores to use for parallel processing. Auto detect (detect = NULL)

save_additional_outputs

specify whether to save outputs such as extracted SNPs and Hamming distance weights. Recommended for very large datasets to save time on re-computation (default = F)

mega_dset

specify whether the datasets is megascale. This mode requires spam and spam64 packages. This is >5 times slower, set to TRUE only if the normal analysis fails (default = F)

Value

All generated outputs will be saved to folder <dset>.

Examples

## Not run: 
# These examples use data included with the package.

# Example 1 - using a full alignment that includes non SNP sites
dset <- "full_dset"
gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
aln_path <- system.file("extdata", "sample.aln.gz", package = "LDWeaver")
LDWeaver::LDWeaver(dset = dset,  aln_path = aln_path,  gbk_path = gbk_path,
                   validate_ref_ann_lengths = F)

# Example 2- using a SNP only alignment
dset <- "snp_dset"
gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
aln_path <- system.file("extdata", "snp_sample.fa.gz", package = "LDWeaver")
pos <- as.numeric(readLines(system.file("extdata", "snp_sample.fa.pos",
                  package = "LDWeaver")))
LDWeaver::LDWeaver(dset = dset,  aln_path = aln_path, aln_has_all_bases = F,
                  pos = pos, gbk_path = gbk_path)

dset <- "full_dset_spam"
gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
aln_path <- system.file("extdata", "sample.aln.gz", package = "LDWeaver")
LDWeaver::LDWeaver(dset = dset,  aln_path = aln_path,  gbk_path = gbk_path,
                   validate_ref_ann_lengths = F, mega_dset = T)

## End(Not run)

make_gwes_plots

Description

Function to generate long and short range GWES plots

Usage

make_gwes_plots(
  lr_links = NULL,
  sr_links = NULL,
  plt_folder = NULL,
  are_srlinks_ordered = F
)

Arguments

lr_links

data.frame containing lr_links or the path to saved lr_links TSV file. Usually output from perform_MI_computation(), (default = NULL). Instead of using this function to generate the lr-gwes plot, use the dedicated LDWeaver::analyse_long_range_links() function for long range link analysis (and plotting).

sr_links

data.frame containing sr_links or the path to saved sr_links TSV file. Usually output from perform_MI_computation(), (default = NULL)

plt_folder

specify the folder to save generated plots (default = NULL, will be saved to a folder called PLOTS in getwd())

are_srlinks_ordered

if False, links will be ordered before plotting, which will plot higher srp links on top of lower ones (default = F). Set True only if the links are already in the preferred order. Note: This function will reverse the link order to match the ggplot's top to bottom plotting order.

Examples

## Not run: 
sr_links_red = perform_MI_computation(snp.dat = snp.dat, hdw = hdw, cds_var = cds_var, ncores = 10,
lr_save_path = "lr.tsv", plt_folder = "plots")

## End(Not run)

extractSNP_from_MSA

Description

Function to extract SNPs from a multi-fasta alignment.

Usage

parse_fasta_alignment(
  aln_path,
  gap_freq = 0.15,
  maf_freq = 0.01,
  method = "default",
  mega_dset = F
)

Arguments

aln_path

path to multi fasta alignment

gap_freq

sites with a gap frequency >gap_greq will be dropped (default = 0.15)

maf_freq

sites with a minor allele frequency <maf_freq will be dropped (default = 0.01)

method

specify the filtering method 'relaxed' or 'default' (default = 'default')

mega_dset

set to TRUE for mega scale datasets (default = F)

Value

R list with SNPs in sparse format and additional parameters

Examples

## Not run: 
aln_path <- system.file("extdata", "sample.aln", package = "LDWeaver")
snp.dat <- parseFastaAlignment(aln_path, gap_freq = 0.15, maf_freq = 0.01, method = "default")

## End(Not run)

extractSNPs_from_SNP_MSA

Description

Function to extract SNPs from a SNP only multi-fasta alignment. This will be the output from running snp-sites.

Usage

parse_fasta_SNP_alignment(
  aln_path,
  pos,
  gap_freq = 0.15,
  maf_freq = 0.01,
  method = "default",
  mega_dset = F
)

Arguments

aln_path

path to multi fasta SNP alignment

pos

numeric vector containing positions in the original alignment

gap_freq

sites with a gap frequency >gap_greq will be dropped (default = 0.15)

maf_freq

sites with a minor allele frequency <maf_freq will be dropped (default = 0.01)

method

specify the filtering method 'relaxed' or 'default' (default = 'default')

mega_dset

set to TRUE for mega scale datasets (default = F)

Value

R list with SNPs in sparse format and additional parameters

Examples

## Not run: 
aln_path <- system.file("extdata", "sample.aln", package = "LDWeaver")
snp.dat <- parseFastaAlignment(aln_path, gap_freq = 0.15, maf_freq = 0.01, method = "default")

## End(Not run)

parse_genbank_file

Description

Function to parse the genbank file for the fasta alignment. Parser built using genbankr source available here: https://github.com/gmbecker/genbankr.

Usage

parse_genbank_file(gbk_path, g = NULL, length_check = T)

Arguments

gbk_path

path to genbank file

g

sequence length, available from the LDWeaver::parse_fasta_alignment() output (default = NULL), required if <length_check = T>

length_check

specify whether to check if fasta and gbk sequence lengths are equal (default = T)

Value

GenBankRecord object

Examples

## Not run: 
aln_path <- system.file("extdata", "sample.aln", package = "LDWeaver")
snp.dat <- parseFastaAlignment(aln_path, gap_freq = 0.15, maf_freq = 0.01, method = "default")
gbk_path <- system.file("extdata", "sample.gbk", package = "LDWeaver")
gbk <- parse_genbank_file(gbk_path, snp.dat$g)

## End(Not run)

parse_gff_file

Description

Function to parse the gff3 file for the fasta alignment.

Usage

parse_gff_file(gff3_path, ref_fasta_path, perform_length_check = T)

Arguments

gff3_path

path to gff3_annotation file. This function relies on ape::read.gff() to read in the file

ref_fasta_path

path to Reference fasta file. The file MUST be in fasta format and contain exactly one sequence!

perform_length_check

specify whether to check if the gff3 annotations agree with the reference length (default = T)

Value

gff annotation and reference sequence as a list object

Examples

## Not run: 
gff3_path <- "<path_to_gff3_file>"
ref_fasta_path <- "<path_to_reference_fasta>"
ref_gff <- parse_gff_file(gff3_path, ref_fasta_path)

## End(Not run)

perform_MI_computation

Description

Function to compute pairwise MI (long range links saved to text file), model the background LD levels within each cluster (plots saved) and compute short-range p-values for each short-range links. If requested, this function can also run the ARACNE algorithm

Usage

perform_MI_computation(
  snp.dat,
  hdw,
  cds_var,
  ncores,
  lr_save_path = NULL,
  sr_save_path = NULL,
  plt_folder = NULL,
  sr_dist = 20000,
  lr_retain_links = 1e+06,
  max_blk_sz = 10000,
  srp_cutoff = 3,
  runARACNE = TRUE,
  perform_SR_analysis_only = FALSE,
  order_links = T,
  mega_dset = F
)

Arguments

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment()

hdw

vector of Hamming distance weights, output from LDWeaver::estimate_Hamming_distance_weights()

cds_var

output from LDWeaver::estimate_variation_in_CDS()

ncores

specify the number of cores to use

lr_save_path

specify the location to save long range MI links as a tsv file (default = NULL, will be auto set)

sr_save_path

specify the location to save short range MI links as a tsv file (default = NULL, will be auto set), links below srp_cutoff will not be saved

plt_folder

specify the folder to save generated plots (default = NULL, will be saved to a folder called PLOTS in getwd())

sr_dist

specify the short-range basepair separation (default = 20000)

lr_retain_links

specify the maximum number of long-range MI links to retain (default = 1000000) - in each block, only a top subset of links will be saved

max_blk_sz

specify maximum block size for MI computation (default = 10000), larger sizes require more RAM

srp_cutoff

specify the short-range -log10(p) cut-off value to discard short-range links before returning the data.frame. This setting has no impact on the modelling since all links are used. However, setting a threshold > 2 will generally reduce the memory usage, plotting time (default = 3, i.e. corresponding to p = 0.001), and run time for ARACNE. If all links are required to be returned, set to 0 (i.e. corresponding to p = 1)

runARACNE

specify whether to run ARACNE on short-range links (default = TRUE), if set to FAULT, all links will be marked as ARACNE=1

perform_SR_analysis_only

skip the long range link analysis (default = FALSE)

order_links

return and save links after sorting in short-range p-value order, most to least important (default = T)

mega_dset

set TRUE for mega scale datasets (default = F)

Value

R data frame with short range GWES links (plots and long range links will be saved)

Examples

## Not run: 
sr_links_red = perform_MI_computation(snp.dat = snp.dat, hdw = hdw, cds_var = cds_var, ncores = 10,
lr_save_path = "lr.tsv", plt_folder = "plots")

## End(Not run)

perform_snpEff_annotations

Description

Function to generate long and short range GWES plots

Usage

perform_snpEff_annotations(
  dset_name,
  annotation_folder,
  snpeff_jar,
  snp.dat,
  cds_var,
  links_df,
  gbk = NULL,
  gbk_path = NULL,
  gff = NULL,
  tophits_path = NULL,
  max_tophits = 250,
  links_type = "SR"
)

Arguments

dset_name

name of the dataset

annotation_folder

folder to save annotatations

snpeff_jar

path to <snpEff.jar>

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment()

cds_var

output from LDWeaver::estimate_variation_in_CDS()

links_df

data.frame containing links (reduced links can be used to save time) output from perform_MI_computation()

gbk

output from parsing the genbank file using LDWeaver::parse_genbank_file() (default = NULL), only provide either GFF3 or GBK annotation

gbk_path

path to genbank file - plan to omit (default = NULL)

gff

output from parsing the gff3 file using LDWeaver::parse_gff_file() (default = NULL), only provide either GFF3 or GBK annotation

tophits_path

specify the path to save tophit links (default = NULL). If NULL, will be saved to annotations_folder/tophits.tsv

max_tophits

specify the number of top hits to return (all links will be annotated and saved to the annotations_folder)

links_type

specify the links type long-range "LR" or short-range "SR" (default = "SR")

Value

R data frame with the top short range GWES links with snpEff annotated embedded

Examples

## Not run: 
sr_links_red = perform_snpEff_annotations(dset_name, annotation_folder, snpeff_jar, gbk,
gbk_path, cds_var, sr_links, snp.dat, max_tophits = 250)

## End(Not run)

read_GFF3_Annotation

Description

read_GFF3_Annotation

Usage

read_GFF3_Annotation(gff3_path)

Arguments

gff3_path

path to gff3_annotation file. This function relies on ape::read.gff() to read in the file, refer to ?ape::read.gff for additional help

Value

parsed annotation file in list format

Examples

## Not run: 
gff3_path = "<path_to_gff3_annotation"
gff = read_GFF3_Annotation(gff3_path)

## End(Not run)

read_ReferenceFasta

Description

read_ReferenceFasta

Usage

read_ReferenceFasta(ref_fasta_path)

Arguments

ref_fasta_path

path to Reference fasta file. The file MUST be in fasta format and contain exactly one sequence!

Value

parsed reference sequence with metadata in list format

Examples

## Not run: 
ref_fa = "<path_to_ref_fasta"
reference = read_ReferenceFasta(ref_fa)

## End(Not run)

read_TopHits

Description

read_TopHits

Usage

read_TopHits(top_hits_path)

Arguments

top_hits_path

path to saved top_hits file

Value

Top hits as a data.frame

Examples

## Not run: 
top_hits_path = "<path_to_tophits_file>"
tophits = read_TopHits(top_hits_path)

## End(Not run)

runARACNE

Description

runARACNE

Usage

runARACNE(links_to_check, links_full)

Arguments

links_to_check

data.frame comprising subset of links to run ARACNE on

links_full

data.frame with all links

Value

Long range links as a data.frame

Examples

## Not run: 
sr_links_path = "<path_to_sr_links.tsv_file>"
sr_links = readShortRangeLinks(sr_links_path)
sr_links_red = sr_links[which(sr_links$srp > 3), ]
sr_links_red$ARACNE = runARACNE(sr_links_red, sr_links)

## End(Not run)

snpdat_to_fa

Description

Create a SNP only fasta or tsv file from snp.dat. The user has the option to include only chosen positions.

Usage

snpdat_to_fa(snp.dat, aln_path, pos_path = NULL, pos = NULL, format = "fasta")

Arguments

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment(), generally saved to Additional_Outputs/snp_ACGTN.rds

aln_path

path to save output fasta file or tsv file

pos_path

path to write the SNP positions, only required for format = "fasta" (default = NULL)

pos

set of loci to be included in the saved alignment (default = NULL - save everything). <pos> should be a numeric vector comprising a subset of sites in snp.dat$POS and cannot contain duplicates

format

Output can be presented as a standard fasta file, or an optional tsv (default = "fasta")


view_tree

Description

Function to visualise allele distributions and metadata aligned below the tree. The tree file must be readable with ape::read.tree() and <tip.labels> must match the sequence names in the provided fasta file(s). Besides the tree file, this function requires minimum three inputs: (1) a links file or data.frame, (2) a SNP fasta alignment and (3) a position <text> file with each row containing the genomic positions of the fasta alignment. The links file is straightforward: it can be either one of <Tophits> or the <Annotated_links> files, both short and long range links can be provided. A subset of manually chosen links can also be provided as a data.frame. The fasta/position files can be generated using LDWeaver::generate_Links_SNPS_fasta(). If metadata is available, they can be visualised along with the allele data in a separate panel.

Usage

view_tree(
  tree_path,
  perform_midpoint_rooting = T,
  metadata_df = NULL,
  fasta_path,
  pos_file_path,
  links_df = NULL,
  lr_tophits_path = NULL,
  lr_annotated_links_path = NULL,
  sr_tophits_path = NULL,
  sr_annotated_links_path = NULL,
  ntop_links = 10,
  from = NULL,
  to = NULL,
  offset_metadata = NULL,
  offset_alleles = NULL,
  width_metadata = NULL,
  width_alleles = NULL,
  plot_save_path = NULL,
  plot_height = 20,
  plot_width = 15
)

Arguments

tree_path

Path to tree file (must be readable using ape::read.tree). tip.labels must exactly match the sequence names in the fasta and metadata files.

perform_midpoint_rooting

Specify wheter the tree should be midpoint rooted (default = T)

metadata_df

data.frame with metadata. Must contain a column labelled 'id' that exactly matches the sequence names in the fasta file and tip.labels of the tree.

fasta_path

fasta file comprising the sites associated with links

pos_file_path

position file containing fasta sites

links_df

A data.frame comprising a subset of tophits links, if provided, links are not read from the files. NOTE: Each links must (at a minimum) contain the fields: <pos1> & <pos2>. If alleles from the <ntop_links> are to be visualised, ensure that the links_df is sorted such that the most important link is at the top.

lr_tophits_path

Path to the lr_tophits file (typically Tophits/lr_tophits.tsv).

lr_annotated_links_path

Path to the lr_annotated_links file (typically Annotated_links/lr_links_annotated.tsv).

sr_tophits_path

Path to the lr_tophits file (typically Tophits/sr_tophits.tsv).

sr_annotated_links_path

Path to the sr_annotated_links file (typically Annotated_links/sr_links_annotated.tsv).

ntop_links

Specify the number of links to plot from tophits file(s). ntop_links will be selected from each file if both LR and SR links should be visualised (default = 10).

from

draw the SNPs that are within the region starting <from> and <to> below (default = NULL). SNPs that are also in links with SNPs from the chosen region will be plotted.

to

If <from> is provided, <to> muts also be provided and <ntop_links> will be ignored (default = NULL).

offset_metadata

specify the separation between tree and metadata layer. These parameters should be modified to tune the plot dimensions as required. (default = NULL)

offset_alleles

specify the speciation between tree and alleles layer (default = NULL)

width_metadata

specify the width of the metadata layer as a proportion of the tree size (default = NULL)

width_alleles

specify the width of the alleles layer as a proportion of the tree size (default = NULL)

plot_save_path

path to save the tree plot (default = NULL, show plot instead of saving)

plot_height

if saving, specify the plot height in inches (default = 20)

plot_width

if saving, specify the plot height in inches (default = 15). Modify these numbers to tune the plot dimensions as required.

Examples

## Not run: 
genomewide_LDMap(lr_links_path, sr_links_path, plot_save_path)

## End(Not run)

write_output_for_gwes_explorer

Description

Function to generate long and short range GWES plots

Usage

write_output_for_gwes_explorer(
  snp.dat,
  tophits,
  gwes_explorer_folder,
  links_type = "SR"
)

Arguments

snp.dat

output from parsing the multi fasta alignment using LDWeaver::parse_fasta_alignment()

tophits

data frame with top short range GWES links, returned from LDWeaver::perform_snpEff_annotations()

gwes_explorer_folder

folder to save the inputs for GWESExplorer

links_type

specify the links type long-range "LR" or short-range "SR" (default = "SR")

Value

none

Examples

## Not run: 
write_output_for_gwes_explorer(snp.dat, tophits, gwes_explorer_folder)

## End(Not run)