Docsity

Big Data Esami passati, Prove d'esame di Database Distribuiti

Toggle sidebar
bg1
February 202 3
(12 points) Distributed Programming
A) [2 points] Briefly describe the di0erence between verti cal scalability and horizontal scalability of distributed systems
(e.g compute clusters). Which is the preferred choice for big data a pplications?
Vert ica l sca lab ili ty increases performance by upgrading a single machine with more resources (e.g., CPU, RAM). It has hardware
limitations and higher costs.
Horizontal scalability distributes the workload across multiple machines (nodes). We can increase the number of nodes, making it more
suitable for big data applications since it allows handling large-scale computat ions eDiciently.
B) [10 points] MapReduce: Consider a l arge dataset (named ‘TCGA-WGS’) of whole-genome seq uencing (WGS) samples S
for a coh ort of tumor pat ients. Each sample s ∈ S is associated with a specific tumor type and to a list of identified somatic
mutations.
Given: a function tumortype(s) which returns the tumor type of the sample s, and a function countmut(s) which returns the
number of somatic mutation identified in sample s.
Tas k: develop the necessary parts of MapReduce algorithm (pseudo code; no specific programming language syntax
required) that computes, across all samples of the dataset, the average number of somatic mutations for each tumor type.
Briefly explain your algorithm (2-3 sentences).
The Map function processes each sample, extracts the tumor type and the number of somatic mutations, and emits them as key-value
pairs (tumor_type, mutation _count).
The Reduce function counts mutations by tum or type, sums them, and calculates the average num ber of mut ations per tumor type by
dividing the total sum by the number of samples.
In general, Map and Reduce are both defined with respect to data st ructured in (key, value) pairs
• Map (transformation): Map(k1, v1) ® list(k2, v2)
• (ShuDle and group by key): one list(k2, v2) per data chunk® ( k2, list(v2) )
à
DONE AUTOMATICALLY BY HA DOOP
• Reduce (aggregation): Reduce( k2, list(v2) ) ® list(k3, v3)
• (Produce final output): output list of all Reduce calls are collected and sorted by key as the final result
pf3
pf4
pf5
pf8
pf9
pfa

Anteprima parziale del testo

Scarica Big Data Esami passati e più Prove d'esame in PDF di Database Distribuiti solo su Docsity!

February 2023

(12 points) Distributed Programming

A) [2 points] Briefly describe the di0erence between vertical scalability and horizontal scalability of distributed systems

(e.g compute clusters). Which is the preferred choice for big data applications?

Vertical scalability increases performance by upgrading a single machine with more resources (e.g., CPU, RAM). It has hardware limitations and higher costs. Horizontal scalability distributes the workload across multiple machines (nodes). We can increase the number of nodes, making it more suitable for big data applications since it allows handling large-scale computations eDiciently.

B) [10 points] MapReduce: Consider a large dataset (named ‘TCGA-WGS’) of whole-genome sequencing (WGS) samples S

for a cohort of tumor patients. Each sample s ∈ S is associated with a specific tumor type and to a list of identified somatic

mutations.

Given : a function tumortype(s) which returns the tumor type of the sample s, and a function countmut(s) which returns the

number of somatic mutation identified in sample s.

Task : develop the necessary parts of MapReduce algorithm (pseudo code; no specific programming language syntax

required) that computes, across all samples of the dataset, the average number of somatic mutations for each tumor type.

Briefly explain your algorithm (2-3 sentences).

The Map function processes each sample, extracts the tumor type and the number of somatic mutations, and emits them as key-value pairs (tumor_type, mutation_count). The Reduce function counts mutations by tumor type, sums them, and calculates the average number of mutations per tumor type by dividing the total sum by the number of samples. In general, Map and Reduce are both defined with respect to data structured in (key, value) pairs

  • Map (transformation): Map(k1, v1) ® list(k2, v2)
  • (ShuDle and group by key): one list(k2, v2) per data chunk® ( k2, list(v2) ) à DONE AUTOMATICALLY BY HADOOP
  • Reduce (aggregation): Reduce( k2, list(v2) ) ® list(k3, v3)
  • (Produce final output): output list of all Reduce calls are collected and sorted by key as the final result

(8 points) Big data management and cloud computing

In the following multiple-choice questions (2 points each), you have to choose the single best answer.

a) Among the three V’s of big data, we find “volume”. This generally refers to...

• … processing high volumes of high-density, structured data

• … processing high volumes of high-density, unstructured data

• … processing high volumes of low-density, unstructured data

• … processing high volumes of low-density, structured data

b) Which of the following architectures or concepts does not address the bottleneck of low data transfer rates to improve

performance?

• Hadoop

• Amazon AWS EC

• Apache Spark

• MapReduce

c) Early data integration refers to …

• … the combination of datasets before processing or data analysis

• … the contemporaneous, joint analysis of multiple datasets.

• … the construction of federated databases.

• … the first step in data warehousing.

d) Results reproducibility refers to …

• … the exact specification of the study protocol in order to allow to precisely replicate

• … the drawing of qualitatively similar conclusions from reanalysis of the original studies.

• … the robustness and generalizability of results, e.g. in an independent study with similar design.

• … the reliability of the study design in terms of its underlying logic.

(12 points) Given a sample dataset in PySpark, created as follows:

> genes = sc.parallelize ( ["TP53", "BRCA1", "AKT3", "STAT3", "PTEN", "MYC", "MYCN", "CTCF"] )

> genes

Answer the following questions:

• [3 points] How gene is stored on the Spark cluster, i.e., as what kind of data … describe the main characteristics

of this sort of structure

The genes dataset is stored as an RDD (Resilient Distributed Dataset) , a fundamental data structure in Spark that allows distributed computation. Resilient Distributed Datasets ( RDDs ) are distributed collections of data that can be processed in parallel across multiple nodes. They are immutable , meaning they cannot be modified once created. Instead, any modification results in the creation of a new RDD. This immutability prevents the overhead of accessing remote memory and simplifies fault tolerance , as modifying existing data would make recovery more complex. To handle failures, Spark maintains lineage information , which records how each RDD was created. This allows Spark to recompute lost data by tracing back the transformation steps using a Directed Acyclic Graph (DAG). Instead of replicating data across nodes, Spark eDiciently reconstructs missing RDD partitions when necessary. How RDDs Are Constructed:

  1. From existing data collections in languages like Python, R or Java, where the user specifies the number of partitions.
  2. From files in HDFS , where each partition typically maps to an HDFS block.
  3. From traditional file systems or databases
  4. Through transformations on existing RDDs , such as applying a map operation to generate a new RDD. The number of partitions in the new RDD depends on the type of transformation applied.

January 2023

1) Domanda sul RegionParser in pyGMQL, era più un piccolo esercizietto

2) Le 3 Vs di Big Data

The Three Vs of Big Data (+ 4th^ V ) represent key characteristics of large datasets:

  1. Volume: refers to the vast amount of data, often low-density and unstructured. In biomedical research , datasets like tumor sequencing or GWAS studies can be massive, though many are well-structured due to ontologies like Gene Ontology.
  2. Velocity: describes the speed at which data is generated and processed. While batch processing is common in computational biology , real-time analysis is crucial in areas like cancer diagnostics , where fast sample analysis can impact patient outcomes.
  3. Variety: reflects the diversity of data formats. Big data includes structured, semi-structured, and unstructured data, requiring additional processing. In biomedical research , integrating multiple data types, such as RNA-seq and clinical records , enhances insights and discoveries.
  4. Veracity: make sure the data is accurate , complete , and useful. It also looks at whether the data is fair or biased , like when most of it comes from just one type of study. Problems like these can sometimes be fixed during later analysis, like using machine learning.

3) Lambda Architecture in cui dovevi spiegare i 3 layers e indicare il flow dei dati di input (cioè che entrano sia nel

batch che nel real time)

The Lambda Architecture , introduced in 2011, is a big data framework that eDiciently processes large-scale data by combining batch processing and real-time processing. It consists of three main layers:

  1. Batch Layer : stores an immutable master dataset where new data is appended without modifying previous entries. This layer performs periodic processing , creating batch views that ensure accuracy but have high latency , meaning results are not updated in real-time.
  2. Real-Time Layer (Speed Layer) : processes incoming data instantly with low latency to provide real-time updates. Unlike the batch layer, it does not store full historical data but prioritizes quick results over absolute accuracy.
  3. Serving Layer : merges outputs from both layers to answer queries eDiciently. It combines accurate but delayed batch results with up-to-date but approximate real-time data, balancing accuracy and speed. Data flows into both the batch and real-time layers simultaneously , ensuring fault tolerance, scalability, and timely insights. This architecture addresses limitations of traditional Hadoop and NoSQL systems , which struggle with high latency and fail to provide real-time analytics. The “cold path” (batch) handles large datasets with high accuracy, while the “hot path” (real-time) delivers quick insights with minimal delay.

4) I vantaggi dell'utilizzo dei workflows

Workflows provide a structured and repeatable process for executing tasks eDiciently, ensuring that activities are well-coordinated and follow a logical sequence. A Workflow Management System (WfMS) automates the execution, scheduling, and monitoring of workflows, improving productivity, reducing costs, and enhancing information exchange. It can handle both human-involved and fully automated computational workflows. Scientific Workflow Systems extend this concept to manage large and complex datasets in fields like bioinformatics and cheminformatics , allowing integration of multiple tools for seamless data processing. In distributed computing environments , workflows are designed through web interfaces , processed by a workflow engine , and executed across multiple servers. This parallelization optimizes resource utilization , speeds up computation, and ensures scalable and reproducible analysis.

5) I 3 modi per ottenere un workflow in Galaxy

  1. Import an existing shared workflow
  2. Construct it manually using the Workflow Editor
  3. Extract the workflow from a history (history options ® extract workflow): probable the most used approach

4) Codice in GMQL già scritto e dovevi spiegare cosa facesse ogni riga. Ti consiglio di guardare gli esempi che ci sono nel

blocco 3 di slide, dalla 58/98 slide. E poi ti chiedeva di modificare qualcosa nel codice per ottenere altro.

5) Gli input e gli output delle funzioni Map e Reduce in MapReduce e se c'è un altro step automatico in mezzo (che è

shu^le and group by key)

The Map function takes a dataset as input and processes each record to produce key-value pairs as output. These key-value pairs are then automatically passed through an intermediate step called Shu]le and Group by Key , where data with the same key is grouped together. Finally, the Reduce function takes these grouped key-value pairs and processes them to generate the final output. Map and Reduce are both defined with respect to data structured in (key, value) pairs

  • Map (transformation): Map(k1, v1) ® list(k2, v2)
  • (ShuDle and group by key): one list(k2, v2) per data chunk ® ( k2, list(v2) )
  • Reduce (aggregation): Reduce( k2, list(v2) ) ® list(k3, v3)
  • (Produce final output): output list of all Reduce calls are collected and sorted by key as the final result

6) La di^erenza dello storage in Apache Spark e Hadoop MapReduce

The key diDerence in storage between Apache Spark and Hadoop MapReduce lies in how data is managed during computation :

  • Hadoop MapReduce relies heavily on HDFS (Hadoop Distributed File System) , where intermediate results are written to disk between each processing stage. This makes Hadoop highly fault-tolerant but significantly slower due to frequent disk I/O operations.
  • In contrast, Apache Spark processes data in-memory whenever possible, storing intermediate results in Resilient Distributed Datasets (RDDs) across the cluster. This allows Spark to perform computations much faster than Hadoop, as it minimizes disk usage. However, Spark still supports disk storage for cases where available memory is insuDicient.

7) Perché gli RDDs non sono modificabili

RDDs (Resilient Distributed Datasets) in Apache Spark are immutable , meaning they cannot be modified after creation. This design choice ensures fault tolerance, parallel execution, and lineage tracking. If RDDs were mutable, updates would require remote memory access, significantly increasing overhead and complexity. Instead of modifying an RDD, Spark applies transformations (such as map or filter) to generate new RDDs. This immutability simplifies fault recovery , as Spark can recompute lost data using the lineage information, which is stored as a DAG (Directed Acyclic Graph) of transformations.

Altre domande di altre sessioni (2023):

1) The three Vs of big data/come si connettono con i dati biologi

2) La quarta V (veracity)-almeno due domande da porsi quando si ricevono dati

Veracity refers to the reliability and accuracy of data. Two important questions when receiving biological data are:

  • Is the data accurate and complete? (Checking for missing values, errors, and standardization)
  • What is the source of the data? (Ensuring it comes from validated experiments, databases, or published studies)

3) Grafico Lambda Architecture, a cosa serve. Descrizione dei tre Layer. I paths dei dati in input (cold e hot path)

4) Una query semplice in GMQL e spiegare cosa faceva un’altra query scritta da lui

5) Esercizio Markov Model (uguale a quello sulle slide del virus/self DNA)

6) IaaS, PaaS, SaaS - esempio per ciascuno + dire chi gestisce i layers

7) Scrivere pseudocode Hadoop per funzione MapReduce per contare parole in un testo (uguale a slide)

8) Crocette su oncognes/tumor suppressor genes

Oncogenes are tumor-promoting genes that normally regulate cell growth and gene transcription. Their activation leads to uncontrolled cell proliferation. This can happen due to overexpression (e.g., MYC in many cancers, BCR-ABL in chronic myelogenous leukemia) or gain-of-function mutations (e.g., BRAF V600E in melanoma). These mutations are often heterozygous since a single mutated copy can drive cancer progression. Tumor Suppressor Genes function to control tumor growth by regulating DNA repair, cell cycle, and apoptosis. Their inactivation leads to loss of cell regulation , allowing mutations to accumulate. Key examples include TP53 (mutated in most cancers), BRCA1/2 (linked to breast and ovarian cancer), and PTEN. Inactivation typically requires both copies to be aDected ( two-hit hypothesis ), but some genes show haploinsu]iciency , where losing just one copy is enough to increase cancer risk. Additionally, hereditary mutations in tumor suppressors, such as BRCA1/2, increase predisposition to cancer. Inactivation can also be caused by epigenetic modifications , like DNA methylation, instead of genetic mutations.

HMMs

Given a sequence of observed output, what is an algorithm which can be used to find the best sequence of hidden states? Briefly describe the algorithm and the formula (initialization, iteration and termination steps) The Viterbi algorithm is used to find the most probable sequence of hidden states given a sequence of observed outputs in a Hidden Markov Model (HMM). It follows a dynamic programming approach, ensuring optimal computation.

  1. Initialization : 𝑉!( 1 ) = π!𝑒! (𝑥$) where 𝑉!( 1 ) is the probability of starting in state k and emitting 𝑥$, π! is the initial probability of state k, and 𝑒!(𝑥$) is the emission probability.
  2. Iteration : For each time step i and state k, 𝑉!(𝑖 + 1 ) = 𝑒!(𝑥"%$) max

2

where 𝑎#! is the transition probability from state j to state k, and the maximum ensures that only the most probable path is considered.

  1. Termination : The most probable final state is: 𝑘∗^ = arg max !

and the best sequence of hidden states is recovered by backtracking from this state. This algorithm ensures eDicient computation of the optimal state sequence with a time complexity of O(NK²) , where N is the length of the observed sequence and K is the number of states.

Cloud Computing

1) PaaS, IaaS, SaaS, serverless services

2) What are the di0erences in the management levels (what do you manage vs what do other manage in each type?)

3) Write an example for each of the four types of services.

Bonus Questions

1) Select the write answer

• Intratumor heterogeneity is independent of clonal evolution

• Intrametastatic heterogeneity is independent of clonal evolution

• Intermetastatic heterogeneity is independent of clonal evolution

• None of the answers is correct

2) Which of this statement is false:

• Early integration consists in the merging of the input data before processing

• (Middle) integration consists of merging of the data in the middle of the analysis

• Late integration consists in the merging of the input datasets at the end of the analysis

January 2025

1) Three Vs Vertical, horizontal scalability di0erence

2) Why data transfer bottleneck and how to overcome it

Bottleneck for big data analysis: data is stored on hard drives and must be transferred to processors for analysis. However, the speed of data transfer has not increased as much as storage capacities and processors often have insuDicient physical memory to handle very large datasets. To overcome this bottleneck, the solution is data locality: distribute data across multiple locations (es. distributed disks or cloud storage) and transfer the application there, allowing diDerent parts of the data to be processed locally and in parallel. However, when using external services, attention must be paid to privacy and security, especially for sensitive data like patient records.

3) Lambda architecture (the layers and complete the image)

4) Genomic Data Model (definition, it's components, a tabular example)

The Genomic Data Model (GDM) represents each biological sample (e.g., tumor or tissue sample) through two key components :

  1. Genometric Data : defines genomic regions mapped to a reference genome , described by chromosome, start and end positions, and strand. Each region may include additional attributes like mutations, read counts, gene expression levels, or statistical values. This structured representation ensures interoperability across diDerent genomic formats (e.g., BED, BAM ).
  2. Metadata : stores sample-specific contextual information using key-value pairs (e.g., patient ID, disease status, smoking history ). It enables flexible comparisons based on biological attributes while maintaining compatibility across datasets. This model eDiciently organizes large-scale genomic data , allowing for integration, querying, and analysis in computational biology.

5) Two functions of Hadoop MapReduce, Shu0le phase

  1. Map Function : processes input data in parallel by applying a user-defined function to each record. It takes input as (key, value) pairs and produces intermediate (key, value) pairs , which are then grouped by key. Example: In word counting, the map function emits (word, 1) for each word in a text.
  2. Reduce Function : aggregates and processes the grouped intermediate data. It takes each unique key and processes its associated values, typically performing operations like summation, filtering, or aggregation. Example: In word counting, it sums occurrences of each word, producing the final count (word, total_count). Between these two steps, an automatic shu]le and group by key phase organizes and groups intermediate data to optimize processing.

6) What information will the script print out

7) How are snps stored on Spark cluster

Single Nucleotide Polymorphisms ( SNPs ) in Apache Spark are typically stored as Resilient Distributed Datasets (RDDs) or DataFrames for eDicient distributed processing. The data is often loaded from formats like VCF (Variant Call Format) , Parquet , or CSV and partitioned across the cluster to enable parallel computation. Each SNP record usually contains fields such as chromosome, position, reference allele, alternate allele, quality scores, genotype information, and annotations.

8) How to improve the code (using chaining)

Chaining in Apache Spark improves eDiciency by reducing intermediate data storage and minimizing the number of actions that trigger jobs. Instead of writing multiple separate transformations (like map(), filter(), and groupBy() in diDerent steps), operations should be chained together in a single pipeline. Example: df.select().sort().show()

9) The purpose of Galaxy workflow (image), What input is needed, what problem if hg

10) Two other options instead of building a workflow from scratch