Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://doi.org/10.5281/zenodo.15690037
18 June 2025, 11:59:23 UTC
  • Code
  • Branches (0)
  • Releases (1)
  • Visits
    • Branches
    • Releases
      • 1
      • 1
    • 6d53078
    • /
    • dmaciel123-BRAZA-b9360a9
    • /
    • Scripts
    • /
    • RUN_flags.R
    Raw File Download

    To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
    Select below a type of object currently browsed in order to display its associated SWHID and permalink.

    • content
    • directory
    • snapshot
    • release
    origin badgecontent badge
    swh:1:cnt:e489c0121342b0aa51b42a28a45b6ce7c5b3f390
    origin badgedirectory badge
    swh:1:dir:800709718798e2ec38f54de29db55bbe58074706
    origin badgesnapshot badge
    swh:1:snp:751ae64375449ec5a7624a34dea2901f039df8e6
    origin badgerelease badge
    swh:1:rel:63f034f46a613d794f3480d38698b1371e3757bc

    This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
    Select below a type of object currently browsed in order to generate citations for them.

    • content
    • directory
    • snapshot
    • release
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    Generate software citation in BibTex format (requires biblatex-software package)
    Generating citation ...
    RUN_flags.R
    # This is the driver script to calculate the quality control flags on the GLORIA Rrs spectra
    # Refer to README.md for a description of the method.
    
    #Loading Required Packages
    
    require(dplyr)
    require(reshape2)
    require(data.table)
    require(tidyr)
    require(data.table)
    require(curl)
    require(polyreg)
    require(Metrics)
    require(openxlsx)
    
    #Loading users function
    
    source('Scripts//baseline_shift.R')
    source('Scripts//Oxygen_peak_calculation.R')
    source('Scripts//UV_Slope.R')
    source("Scripts/QWIP.R")
    
    #Read the Gloria Rrs file in Excel format
    gloria_rrs = read.xlsx('Data/rrs.xlsx')
    
    
    # Use GLORIA Nomenclature
    names(gloria_rrs)= c('GLORIA_ID', paste('Rrs_', c(400:900), sep = ''))
    
    
    for(i in 2:ncol(gloria_rrs)) {
      
      gloria_rrs[,i] = as.numeric(gloria_rrs[,i])
      
    }
    
    
    #Basline Calculation
    negatives = negative_slopes(gloria_rrs =  gloria_rrs)
    baseline = baseline_shift(gloria_rrs =  gloria_rrs)
    
    baseline_shifts = merge_baseline_negative(GLORIA_ID = negatives$GLORIA_ID,
                                            baseline = baseline$baseline, 
                                            negative = negatives$negative_slopes)
    
    #Oxygen Peak Calculation
    oxygen_peak <- data.frame(GLORIA_ID=gloria_rrs$GLORIA_ID, 
                         Oxy_peak_height = apply(select(gloria_rrs, 
                                                        paste("Rrs_",seq(400,900),sep="")),1,
                                                        OAI_Dalin,wave_min=400,
                                                        wave_max=900,wave_int=1)) %>% flag_creation()
    
    #Noise Red Edge Calculation
    NOISE_RED_EDGE = noise_red_edge(gloria_rrs = gloria_rrs)
    
    
    #Counting number of flags for each method
    
    filter(baseline_shifts, Baseline_shift == 1) %>% nrow() 
    filter(oxygen_peak, flag == 1) %>% nrow() 
    filter(NOISE_RED_EDGE, flag == 1) %>% nrow() 
    
    
    ## Merged Results 
    
    final_results = data.frame(GLORIA_ID = baseline_shifts$GLORIA_ID, 
                               Baseline_shift = baseline_shifts$Baseline_shift, 
                               Oxygen_signal = oxygen_peak$flag, 
                               Noisy_red = NOISE_RED_EDGE$flag)
    
    # Check Final Results 
    
    filter(final_results, Baseline_shift == 1) %>% nrow() 
    filter(final_results, Oxygen_signal == 1) %>% nrow() 
    filter(final_results, Noisy_red == 1) %>% nrow() 
    
    
    final_results$Suspicious = 0
    
    for(i in 1:nrow(final_results)) {
      
      ID = final_results$GLORIA_ID[i]
      
      if(file.exists(paste('Data/Suspicious/', ID, '.jpeg', sep = '')) == T) {
        
        
        final_results$Suspicious[i] = 1
        
        
      }
      
      
    }
    
    
    
    final_results$Noisy_red[is.na(final_results$Noisy_red)] = 0
    
    # Run QWIP 
    
    QWIP_Res = QWIP(data = gloria_rrs)
    
    
    # Save all results 
    
    final_results$QWIP = abs(estacoes$QWIP)
    
    final_results$QWIP[final_results$QWIP > 0.2] = 1
    final_results$QWIP[final_results$QWIP <= 0.2] = 0
    
    
    
    write.csv(file = 'Data/flags.csv', x = final_results, na = 'NaN', row.names = F)
    
    
    
    
    
    
    
    

    back to top

    Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
    The source code of Software Heritage itself is available on our development forge.
    The source code files archived by Software Heritage are available under their own copyright and licenses.
    Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API