Skip to contents

Get genes based on their differential regulation

Usage

get_genes_by_regulation(
  x,
  sample_comparisons,
  regulation = "both",
  simplify = FALSE
)

get_genesets_by_regulation(x, sample_comparisons, regulation = "both")

Arguments

x

an abject of class "parcutils". This is an output of the function run_deseq_analysis().

sample_comparisons

a character vector denoting sample comparisons for which genes to be obtained.

regulation

a character string, default both. Values can be one of the up, down, both, other, all.

  • up : returns all up regulated genes.

  • down : returns all down regulated genes.

  • both : returns all up and down regulated genes.

  • other : returns genes other than up and down regulated genes.

  • all : returns all genes.

simplify

logical, default FALSE, if TRUE returns result in a dataframe format.

Value

a list or dataframe.

Details

For a given differential comparison this function returns up, down, both, other and all genes.

Examples

count_file <- system.file("extdata","toy_counts.txt" , package = "parcutils")
count_data <- readr::read_delim(count_file, delim = "\t")
#> Rows: 5000 Columns: 10
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: "\t"
#> chr (1): gene_id
#> dbl (9): control_rep1, control_rep2, control_rep3, treat1_rep1, treat1_rep2,...
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.

sample_info <- count_data %>% colnames() %>% .[-1]  %>%
 tibble::tibble(samples = . , groups = rep(c("control" ,"treatment1" , "treatment2"), each = 3) )


res <- run_deseq_analysis(counts = count_data ,
                         sample_info = sample_info,
                         column_geneid = "gene_id" ,
                         group_numerator = c("treatment1", "treatment2") ,
                         group_denominator = c("control"))
#>  Running DESeq2 ...
#> converting counts to integer mode
#> Warning: some variables in design formula are characters, converting to factors
#> estimating size factors
#> estimating dispersions
#> gene-wise dispersion estimates
#> mean-dispersion relationship
#> final dispersion estimates
#> fitting model and testing
#>  Done.
#>  Summarizing DEG ...
#>  Done.

# get both up and down regulated genes
get_genes_by_regulation(x = res, sample_comparisons = c("treatment1_VS_control")) %>% head()
#>   ENSG00000250305:TRMT9B    ENSG00000134308:YWHAQ  ENSG00000123575:FAM199X 
#>                     down                     down                     down 
#> ENSG00000148482:SLC39A12    ENSG00000175264:CHST1    ENSG00000141933:TPGS1 
#>                     down                     down                     down 
#> Levels: up down other

# get up genes only
get_genes_by_regulation(x = res, sample_comparisons = c("treatment1_VS_control") , regul = "up") %>% head()
#>       ENSG00000187193:MT1X ENSG00000269533:AC003002.3 
#>                         up                         up 
#>      ENSG00000065427:KARS1       ENSG00000007171:NOS2 
#>                         up                         up 
#>     ENSG00000285447:ZNF883      ENSG00000111275:ALDH2 
#>                         up                         up 
#> Levels: up down other

# get down genes only
get_genes_by_regulation(x = res, sample_comparisons = c("treatment1_VS_control") , regul = "down") %>% head()
#>   ENSG00000250305:TRMT9B    ENSG00000134308:YWHAQ  ENSG00000123575:FAM199X 
#>                     down                     down                     down 
#> ENSG00000148482:SLC39A12    ENSG00000175264:CHST1    ENSG00000141933:TPGS1 
#>                     down                     down                     down 
#> Levels: up down other

# get genes other than up and down
get_genes_by_regulation(x = res, sample_comparisons = c("treatment1_VS_control") , regul = "other") %>% head()
#> ENSG00000154342:WNT3A ENSG00000196415:PRTN3  ENSG00000173020:GRK2 
#>                 other                 other                 other 
#>  ENSG00000140598:EFL1 ENSG00000139263:LRIG3 ENSG00000165898:ISCA2 
#>                 other                 other                 other 
#> Levels: up down other

# Simplify output for multiple sample comparisons
get_genes_by_regulation(x = res, sample_comparisons = res$de_comparisons, simplify = TRUE, regul= "up")
#> $treatment1_VS_control
#> # A tibble: 13 × 3
#>    sample_comparisons    genes                      regul
#>    <chr>                 <chr>                      <fct>
#>  1 treatment1_VS_control ENSG00000187193:MT1X       up   
#>  2 treatment1_VS_control ENSG00000269533:AC003002.3 up   
#>  3 treatment1_VS_control ENSG00000065427:KARS1      up   
#>  4 treatment1_VS_control ENSG00000007171:NOS2       up   
#>  5 treatment1_VS_control ENSG00000285447:ZNF883     up   
#>  6 treatment1_VS_control ENSG00000111275:ALDH2      up   
#>  7 treatment1_VS_control ENSG00000279111:OR10X1     up   
#>  8 treatment1_VS_control ENSG00000167617:CDC42EP5   up   
#>  9 treatment1_VS_control ENSG00000186566:GPATCH8    up   
#> 10 treatment1_VS_control ENSG00000232423:PRAMEF6    up   
#> 11 treatment1_VS_control ENSG00000182103:FAM181B    up   
#> 12 treatment1_VS_control ENSG00000172500:FIBP       up   
#> 13 treatment1_VS_control ENSG00000151033:LYZL2      up   
#> 
#> $treatment2_VS_control
#> # A tibble: 333 × 3
#>    sample_comparisons    genes                   regul
#>    <chr>                 <chr>                   <fct>
#>  1 treatment2_VS_control ENSG00000155918:RAET1L  up   
#>  2 treatment2_VS_control ENSG00000151458:ANKRD50 up   
#>  3 treatment2_VS_control ENSG00000110876:SELPLG  up   
#>  4 treatment2_VS_control ENSG00000128510:CPA4    up   
#>  5 treatment2_VS_control ENSG00000153815:CMIP    up   
#>  6 treatment2_VS_control ENSG00000130005:GAMT    up   
#>  7 treatment2_VS_control ENSG00000091542:ALKBH5  up   
#>  8 treatment2_VS_control ENSG00000157240:FZD1    up   
#>  9 treatment2_VS_control ENSG00000103154:NECAB2  up   
#> 10 treatment2_VS_control ENSG00000112379:ARFGEF3 up   
#> # … with 323 more rows
#> 


# get genesets by regulation. It uses sample comparison and regulation to name each output geneset.

get_genesets_by_regulation(x = res, sample_comparisons = "treatment1_VS_control", regul = "both")
#> $treatment1_VS_control_down
#>  [1] "ENSG00000250305:TRMT9B"   "ENSG00000134308:YWHAQ"   
#>  [3] "ENSG00000123575:FAM199X"  "ENSG00000148482:SLC39A12"
#>  [5] "ENSG00000175264:CHST1"    "ENSG00000141933:TPGS1"   
#>  [7] "ENSG00000165621:OXGR1"    "ENSG00000104081:BMF"     
#>  [9] "ENSG00000278023:RDM1"     "ENSG00000172264:MACROD2" 
#> [11] "ENSG00000162971:TYW5"     "ENSG00000198682:PAPSS2"  
#> [13] "ENSG00000125445:MRPS7"    "ENSG00000138670:RASGEF1B"
#> [15] "ENSG00000124839:RAB17"    "ENSG00000069869:NEDD4"   
#> [17] "ENSG00000174576:NPAS4"    "ENSG00000143514:TP53BP2" 
#> [19] "ENSG00000181009:OR52N5"   "ENSG00000257315:ZBED6"   
#> [21] "ENSG00000141748:ARL5C"    "ENSG00000198886:MT-ND4"  
#> [23] "ENSG00000157045:NTAN1"    "ENSG00000165131:LLCFC1"  
#> [25] "ENSG00000277611:Z98752.3" "ENSG00000158089:GALNT14" 
#> [27] "ENSG00000124784:RIOK1"    "ENSG00000103197:TSC2"    
#> 
#> $treatment1_VS_control_up
#>  [1] "ENSG00000187193:MT1X"       "ENSG00000269533:AC003002.3"
#>  [3] "ENSG00000065427:KARS1"      "ENSG00000007171:NOS2"      
#>  [5] "ENSG00000285447:ZNF883"     "ENSG00000111275:ALDH2"     
#>  [7] "ENSG00000279111:OR10X1"     "ENSG00000167617:CDC42EP5"  
#>  [9] "ENSG00000186566:GPATCH8"    "ENSG00000232423:PRAMEF6"   
#> [11] "ENSG00000182103:FAM181B"    "ENSG00000172500:FIBP"      
#> [13] "ENSG00000151033:LYZL2"     
#>