コード例 #1
0
    def __init__(self, args):
        """
        These arguments are specifically to assist with PGS SummaryCLeaner
        """
        super().__init__(args)
        self._config = self.config["Summary"]

        # Set the write directory for Summary Files
        self.make_sub_directory("PGS", "Cleaned")
        self.summary_directory = Path(self.working_dir, "PGS", "Cleaned")

        # Validate the summary file, and set the load type, sample size and header indexing
        self.summary_file = mc.validate_path(self.args["Summary_Path"])
        self.zipped, self.sample_size = self._set_summary_stats()
        self._summary_headers = self._set_summary_headers()

        # Determine effect type, and load the configuration of alleles, set z scores if requried
        self.effect_type = self._set_effect_type(
            self.args["Summary_Effect_Type"])
        self.ambiguous_snps, self.allowed_alleles, self.allele_flip = self._configure_alleles(
        )
        self.z_scores = self._set_z_scores(self.args["Z_Scores"])

        self.summary_headers, self.summary_dict = self._set_summary_write_headers(
        )
コード例 #2
0
    def __init__(self, args):
        """
        These attributes are or can be used by multiple processors so are not restricted to sub-loaders
        :param args:
        """
        super().__init__(args)

        self.target_chromosome = self.args["Target_Chromosome"]

        # Internal data brought across with package, loaded if requested
        self.hap_map_3 = self._load_local_data_path("HapMap3")
        self.lr_ld_path = self._load_local_data_path("Filter_Long_Range_LD")

        # Genetic files attributes
        self.gen_directory = validate_path(self.args["Load_Directory"])
        self.gen_type = self.args["Load_Type"]
        self._snp_tools = self.args["PySnpTools_Bgen"]

        # PySnpTools will by default write memory files to the directory of the Gen files, but this is often undesirable
        # on a sever environment where read and write permissions may not be universal.
        if self._snp_tools:
            self.make_sub_directory(None, "PySnpTools_Meta")
            custom_meta_path(Path(self.working_dir, "PySnpTools_Meta"))

        # A list of iid to be used for a reference panel if required
        self.ref_panel = self._set_reference_panel()
コード例 #3
0
    def _set_reference_panel(self):
        """
        Many operations will need a reference panel of individuals that are genetically dis-similar/ Not related to each
        other. This will load a csv or similar text file with two columns of type FID - IID if set. Else will return
        None.

        Note
        -----
        This operation does NOT allow for headers, so do not set them!
        """
        if self.args["Reference_Panel"]:
            path_to_file = Path(self.args["Reference_Panel"])
            validate_path(path_to_file, False)
            return CsvObject(path_to_file, set_columns=True, file_headers=False).row_data

        else:
            return None
コード例 #4
0
    def __init__(self, args):
        """
        Loads args into memory to be used by other Loaders to initialise Input

        Contains common names as attributes so that they can be used as arguments to avoid spelling/alternative naming
        where-ever possible
        """
        self.args = set_args(args)
        self.working_dir = validate_path(self.args["Working_Directory"], False)
        self.config = load_yaml(Path(Path(__file__).parent, "Config.yaml"))
コード例 #5
0
    def __init__(self, args):
        """
        This Class Loads all other Loaders that represent specific or common attributes/methods that are used across
        processors.

        Methods or attributes set within this class are dependent on multiple attributes from its inherited sub class or
        are specific to Input

        :param args: Args Passed by the users
        """
        super().__init__(args)

        # General operational parameters
        self.operation = set_current_job(self.args["Operation"])
        self.iter_size = self.args["Iter_Size"]

        # Score information
        self.make_sub_directory("PGS", "Scores")
        self.scores_directory = Path(self.working_dir, "PGS", "Scores")
        # todo expose this but have a default
        self.score_type = "Inf_Weights"
        self.phenotype_file = validate_path(self.args["Phenotype"])
        self.covariates_file = validate_path(self.args["Covariates"])