Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR to fix krona plots #51

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
zamp.egg-info/
zamp/__pycache__
zamp/ressources/
zamp/ressources/
build/
1 change: 1 addition & 0 deletions zamp/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ if os.path.isdir(INPUT) and METADATA:
SAMPLES.set_index("sample", inplace=True)
elif os.path.isfile(INPUT) and not METADATA:
SAMPLES = pd.read_csv(INPUT, sep="\t", index_col="sample")
METADATA = INPUT


# Add read pairing
Expand Down
1 change: 0 additions & 1 deletion zamp/rules/5_visualization/General_plotting.rules
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ rule KRONA_plots:
params:
grouping_column=lambda wildcards: wildcards.grouping_column,
grouping_col_value=lambda wildcards: wildcards.grouping_col_value,
sample_label="sample",
log:
os.path.join(
dir.logs,
Expand Down
7 changes: 2 additions & 5 deletions zamp/rules/5_visualization/scripts/KRONA_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
output_folder <- (dirname(output_folder)[1])

## Parameters
sample_label <- snakemake@params[["sample"]]
grouping_column <- snakemake@params[["grouping_column"]]
grouping_filter_column_value <- snakemake@params[["grouping_col_value"]]

Expand All @@ -30,10 +29,8 @@
melted_dataframe<- read.csv(file.path(phyloseq_melted_table), header = TRUE, sep = "\t")

## Create KRONA
df <- filter(melted_dataframe, melted_dataframe[[grouping_column]] == grouping_filter_column_value)
df <- filter(df, df[["Abundance"]] != 0)

df <- df[, c("Abundance", sample_label, "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "OTU")]
df <- subset(melted_dataframe, sample_group == grouping_filter_column_value & Abundance !=0)
df <- df[, c("Abundance", "Sample", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "OTU")]
df <- as.data.frame(unclass(df))
df[, 2] <- gsub(" |\\(|\\)", "", df[, 2])
df[, 2] <- as.factor(df[, 2])
Expand Down